Skip to content Skip to sidebar Skip to footer

Get Path Of File Uploaded To Flask

I have a Python web application that runs locally in a web browser for interface convenience, processes files that a user selects, and saves processed data. I need to add the featu

Solution 1:

In order to not expose unnecessary information about the client's system, only the filename is sent with the HTTP request. The full path is not sent. Take a look at an HTTP multipart/form-data request:

Content-Type: multipart/form-data; boundary=AaB03x

--AaB03x
Content-Disposition: form-data; name="submit-name"

Larry
--AaB03x
Content-Disposition: form-data; name="files"; filename="file1.txt"
Content-Type: text/plain

... contents of file1.txt ...
--AaB03x--

As you can see, information is pretty minimal. The path is not provided.

Similarly, the File API only allows access the filename.

So unfortunately, you won't be able to get the full path from a file input.

Post a Comment for "Get Path Of File Uploaded To Flask"