帮助将图像上传到 EC2 实例(Flash -> PHP)

发布于 2024-08-05 05:13:54 字数 971 浏览 1 评论 0原文

我开发了一个图像上传应用程序,它使用 Flash 加载图像、调整图像大小并将图像数据的字节数组发送到 PHP 文件,该文件使用以下代码输出调整大小的文件 -

$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";
}

当我从专用的 Windows 2003 Web 服务器,但现在我尝试在 EC2 实例上运行它,它已停止工作,我只收到“文件上传失败”消息。我可以从 Firefox 的 Firebug 附加组件看出,字节数组数据已正常发布到 EC2 实例,但无法看出还有什么原因会导致问题。

在 EC2 上,我正在运行安装了 PHP 和 Apache 的 CentOS 映像,我不知道从哪里开始解决这个问题!请告诉我我需要在这里寻找什么问题,有什么想法吗?

我检查了错误日志并收到以下错误消息 -

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

这是否与指向错误目录有关?或像下面有人所说的权限?如何授予 PHP 写入此目录的权限?我应该使用绝对路径来引用我想要写入图像的目录吗?

干杯

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请止步禁区 2024-08-12 05:13:54

可能是权限问题,可能是php用户没有写入指定目录的权限。

apache 错误日志中是否有任何消息?

Could be a permission problem, maybe the php user does not have permission to write to the specified directory.

Do you have any messages in the apache error log?

叹倦 2024-08-12 05:13:54

我不知道您是否愿意与其他课程一起工作,但是有一些 PHP EC2 课程可能会有所帮助 - http://sourceforge.net/projects/php-ec2/

I don't know if your willing to work with other's classes, but there are a few PHP EC2 classes around which may help - http://sourceforge.net/projects/php-ec2/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文