Curl: (26) could not open the file

I get this error when I try to call the api field via curl.

curl: (26) couldn't open file 

I can not find why! I call this api with the correct file name -

 curl https://upload.view-api.box.com/1/documents \ -H "Authorization: Token YOUR_API_TOKEN" \ -H "Content-type: multipart/form-data" \ -F file=@A _correct_file_name 

I saw all three questions already asked, but 2 of them remained unanswered, and one for facebook.

Error cURL 26 could not open file

Fatal error: Uncaught CurlException: 26: Could not open file "" thrown at

Getting Fatal Error Uncaught CurlException: 26: Could not open file

+6
source share
4 answers

Sorry guys! To blame. I did not include the file extension in the file name. After turning it on, it worked. I will answer this if someone makes the same mistake in the future.

+4
source

I had a similar problem after switching to PHP 5 (I used the @ download method and it was deprecated, so I had to start using CURLFile ) and a solution to my problem was found in this stack .

Solution: loading curl will not work with relative paths, use the full path instead

+14
source

I had a similar problem with relative paths like @Guilherme. I ran my bash script with:

 bash test/script.sh 

However, my file was at the same directory level as the bash script, and not the test directory (where I called bash), so the script could not find my file.

Solution for me:
1. cd in / test and run bash script.sh from there 2. Use absolute paths

+2
source

I had this problem this morning, but I solved it with this

 fileUpload=@ \"file, with comma .txt\" 

So you should put some double quotes around the file name if you have commas in the file name (\ ")

+1
source

Source: https://habr.com/ru/post/969487/


All Articles