Reputation: 11
In cloudinary php i have the required files and set my config too but when i try to upload a picture from php file
\Cloudinary\Uploader::upload("1.png");
i get error
( ! ) Fatal error: Uncaught exception 'Exception' with message 'Error in sending request to server - couldn't open file in C:\wamp\www\demo\src\Uploader.php on line 200
Exception: Error in sending request to server - couldn't open file "1.png" in C:\wamp\www\demo\src\Uploader.php on line 200
Call Stack
Upvotes: 1
Views: 2466
Reputation: 5928
I might as well provide an answer here because I had the same exact problem, contacted Cloudinary's support team, and their solution worked.
First, I have an images
folder and keep all of them there.
\Cloudinary\Uploader::upload('images/image1.jpg');
That caused the same error you got. I then changed it to:
\Cloudinary\Uploader::upload("C:\\xampp\\htdocs\\test\\images\\image1.jpg");
That worked perfectly. However, I didn't want to use absolute paths, so that's why I contacted their support team. This is the code that works:
\Cloudinary\Uploader::upload( $_SERVER['DOCUMENT_ROOT'] . "/test/images/image1.jpg");
The test
value in that string is the directory of my site, inside the htdocs
folder.
Upvotes: 0
Reputation: 1457
The uploader cannot find the file you are trying to upload. Try to put the 1.png file in the same directory as the php file and run:
\Cloudinary\Uploader::upload(realpath(dirname(__FILE__).'/1.png'));
Upvotes: 3
Reputation: 1109
Sounds like 1.png is hardcoded somewhere and your parameter is not taken into account. Try to do a project wide search for 1.png and see if you can replace that with a parameter.
Upvotes: 0