Upload File with CURL into Website Upload File with CURL into Website curl curl

Upload File with CURL into Website


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


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.


Instead of -F, we have to use --form-string. Then it will work.