0

I have installed lamp server on a EC2 instance, and then Wordpress following https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress.html#hosting-wordpress-prereqs

Now I have installed a plugin which works fine on other servers. This plugin has a GUI interface for users using my website, and at some moment they have to upload an image. This image is used for a curl. However, I'm getting curl error 26 after performing a curl, which I couldn't see in my local server. I suspect the error comes from the line:

 $cFile = curl_file_create($_REQUEST["image"]);

Because if I echo $_REQUEST["image"] I can see an stream of an image in bytes correctly, but, if I echo $cFile I get an error 500 from server. Later I use this $cFile for

curl_setopt($ch, CURLOPT_POSTFIELDS, $cFile);

Do I have any problems of permissions? What do I have to do?

Learning from masters
  • 2,032
  • 3
  • 29
  • 42
  • Because `curl_file_create` first argument is `string $filename: Path to the file which will be uploaded.` - You must provide path to file, not file content. – Justinas Jul 14 '22 at 09:15
  • 1
    Does this answer your question? [Send string as a file using curl and php](https://stackoverflow.com/questions/6149985/send-string-as-a-file-using-curl-and-php) – Justinas Jul 14 '22 at 09:17
  • But in my local server I'm not recieving this error and it's working... I'm using here php 7.2 btw – Learning from masters Jul 14 '22 at 09:52
  • Have you turned on error reporting in local environment? – Justinas Jul 14 '22 at 10:08

1 Answers1

0

Curl error 26 is usually a READ_ERROR. Since this is working locally, but not on your EC2 instance, you might not have permission to write in the correct directory. Make sure your target directory is readable by the appropriate system user. This will be whatever user is running the apache process.

Try running ps -axu | grep apache or ps -axu | grep httpd on your EC2 to see the right user, then check their read permission for your target directory.

Just don't go overboard on permissions and make sure you only give write and execute to directories you know to be safe.

JasonQ-AWS
  • 36
  • 4