I have developed an image uploading application that uses Flash to load an image, resize the image and send the bytearray of the image data to a PHP file that outputs the resized file using the following code -
$default_path = '/uploads/temp/';
$filename = $_GET["filename"];
$destination = $default_path . $filename;
if(file_put_contents($destination, $GLOBALS["HTTP_RAW_POST_DATA"])) {
echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";
} else {
echo "FILE UPLOAD FAILED";
}
This worked great when I was running it from a dedicated windows 2003 web server but now that I am trying to run this on an EC2 instance it has stopped working and I only get the "File Upload Failed" message. I can tell from Firefox's Firebug add-on that the bytearray data is being posted to the EC2 instance ok but cannot see what else would be causing the problem.
on EC2 I am running a CentOS image with PHP and Apache installed, I dont event know where to start troubleshooting this one! Please tell me what issues i need to be looking for here, any ideas?
I checked the error logs and get the following error message -
file_put_contents(/uploads/temp/abcdefg.JPG) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: No such file or directory
Is this to do with pointint to the wrong directory? or permissions as someone has stated below? How do I give PHP permission to write to this directory and should I use absolute path to reference the directory I want to write the image to?
cheers