Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload File with CURL into Website

I try to Upload a File into a Website with cURL on Windows CMD. The html-code looks like this:

<form enctype="multipart/form-data" action="/Filebrowser?Path=/S71500/" method="POST" onsubmit="return checkUploadFile()">
<td><input id="filebrowser_upload_filename" type="file" name="filename" size="30" maxlength="80" style="background-color: transparent;"></td>
<td><input type="submit" value="Datei laden"></td> 
</form>

The command i am using is:

curl -F "filename=@/Users/Me/FILE.so" http://localhost:8080

The fail-message is:

Warning: setting file FILE.so failed!
curl: (26) read function returned funny value

What am I doing wrong?

like image 422
Flo.rian Avatar asked Jan 05 '18 14:01

Flo.rian


2 Answers

for me, it was a permissions thing. Curl wasn't able to read my file because it wasn't readable. try:

sudo chmod a+r /path/to/your/file

also, make sure to verify that you are logged in as either root or the owner of the file

ls -l /path/to/your/file

will give you info about permissions, ownership, and group for example:

-rw-r--r-- 1 me users 792139 Jul  2 11:23 file.txt

file.txt is readable by root, "me" and members of the group "users" - writable only by root, and not executable by anyone. it contains 792139 bytes

like image 159
spinach Avatar answered Oct 13 '22 10:10

spinach


I had the exact same error, while trying to upload with curl:

Warning: setting file testimage.png’  failed!

It comes out to be because my curl command line contained spurious invisible characters from a copy/paste from browser. I copied the command line into a text editor like Sublime Text and then back into terminal: suddenly everything worked.

Probably some UTF8 / ASCII issue.

like image 40
Josef Grunig Avatar answered Oct 13 '22 10:10

Josef Grunig