I’m trying to receive an image from a user and then upload it to my Amazon S3 account, but I’m getting the error Warning: move_uploaded_file(/items) [function.move-uploaded-file]: failed to open stream: Permission denied from Zend Framework. I set the permissions on the folder to 777 through FTP but I’m still getting the error. Here’s the code producing the error, on the off chance that it makes a difference. The error is coming up on the receive, I would assume. How can I get rid of this error?
$upload = new Zend_File_Transfer();
$upload->addValidator('ImageSize', false, array('minwidth' => 100,
'maxwidth' => 1000,
'minheight' => 100,
'maxheight' => 1000), 'image')
->addValidator('Extension', false, 'jpg')
->addValidator('Count', false, array('min'=>0, 'max'=>2));
if($upload->isUploaded('image')){ //Pic was uploaded
if($upload->isValid('image')){ //Pic is valid
echo "Pic provided is valid.";
$upload->addFilter('Rename',array('target'=>"/items/{$item_id}_nla.jpg",'overwrite'=>true));
$upload->receive();
$pic = "/items/{$item_id}_nla.jpg";
$s3->putObject("media.completeset.com/images/items/{$item_id}_nla.jpg", $pic,
array(Zend_Service_Amazon_S3::S3_ACL_HEADER => Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ,
Zend_Service_Amazon_S3::S3_CONTENT_TYPE_HEADER => "image/jpeg"));
echo "Pic is uploaded.";
}
echo "Pic is invalid.";
}
Change the directory so it is absolute:
Or remove the first
/if you are already in the project root.