Lucas Spangher Lucas Spangher - 1 year ago 75
HTML Question

Where to find the file after uploading via Flask/Python/Heroku?

I followed the basic format of how to upload a file on the following question: Flask/Apache submit button for file upload

And my web page now has an upload and submit button that, I believe, works (i.e. it doesn't go to an error page, but just goes back to the index.html form to submit a file again.

My question is, I assume that a file is being uploaded somewhere. Where is it? Is it on my harddrive (preferably not!) or in the web somewhere? It would be really cool to be able to access that file in the python backend and then call a function on it. (Eventually, I would like to return a file, too, that the backend produces).

Can anyone help point me in the right direction? I guess my questions are:

My code looks like the fixed code in the question I linked to.

  1. Where is the file and how can I call it for use later in the .py document?

  2. If my file is on my hard drive in the /tmp/ folder, how do I change it so it just stays on the web?

  3. How do I send a file back? Is it HTTP "PUT"?

Answer Source
  1. The file is at

    filename = secure_filename(file.filename)"/tmp/", filename))

which means whatever filename is, in the /tmp/ directory.

  1. No. It should be in /tmp/ filename. Although I don't think this is a valid location for heroku. I suspect you have to upload content to someplace else, like Amazon S3 or direct via node.

  2. The online location, such as S3 will have a url, which you embed into the html so it downloads directly. eg<filename>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download