Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Open unuploaded file
#1
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 = requests.post(SERVER, files=files)
And in the server:
file = request.files['file']
print(file)
I get the following error:
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.
Quote
#2
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.
Feel like you're not getting the answers you want? Checkout the help/rules for things like what to include/not include in a post, how to use code tags, how to ask smart questions, and more.

Pro-tip - there's an inverse correlation between the number of lines of code posted and my enthusiasm for helping with a question :)
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Open Sqlite database file directly in django sourabhjaiswal92 0 891 May-22-2018, 05:55 AM
Last Post: sourabhjaiswal92
  Cannot open file [ERNO 22] INVALID ARGUMENT JoshuaKim02 20 4,429 Jan-04-2018, 07:05 PM
Last Post: JoshuaKim02

Forum Jump:


Users browsing this thread: 1 Guest(s)