Python Forum

Full Version: Open unuploaded file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm using Flask and requests module. And I'm trying to use post request:

file = request.files['file']
files = {'file': open(file.filename)}
r =, files=files)
And in the server:
file = request.files['file']
I get the following error:
files = {'file': open(file.filename)}\nFileNotFoundError: [Errno 2] No such file or directory: 'run.gif'
I think what I'm doing here is open(file.filename) is not reading the uploading file. Because, it doesn't read full path.

So, how can I read temp file?

Or, I'm doing something wrong? Should I send stream data to the server? If so, how should I do that? Please help me understanding to send file to the server.
Can you open the file with a script which does only that?

I feel like I need more context on this question. You should provide full, runnable code that reproduces your problem, with the minimum reasonable code necessary to reproduce it. I would estimate 10-20 lines, but if you're posting >50 it's definitely too much.