【发布时间】:2013-07-06 01:26:37
【问题描述】:
我在将图像上传到 S3 时遇到问题。我正在使用 S3 类和 jqueryimageuploader 插件。 我已经设置了基本应用程序,它在我的本地机器上运行良好。当我将它部署在 beanstalk 上时,它开始抛出错误。我已经附上了控制台快照。 我在这里添加我的代码以供参考。 这是启动文件 index.html -
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>jQuery File Upload Example</title>
</head>
<body>
<input id="fileupload" type="file" name="files[]" data-url="http://mydomain.elasticbeanstalk.com/server/php/index.php" multiple>
<script src="js/jquery.min.js"></script>
<script src="js/vendor/jquery.ui.widget.js"></script>
<script src="js/jquery.iframe-transport.js"></script>
<script src="js/jquery.fileupload.js"></script>
<script>
$(function () {
$('#fileupload').fileupload({
dataType: 'json',
done: function (e, data) {
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo(document.body);
});
}
});
$('#fileupload').fileupload({
/* ... */
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .bar').css(
'width',
progress + '%'
);
}
});
});
</script>
<style>
.bar {
height: 18px;
background: green;
}
我的 index.php --> 这是在文件上传点击时调用的
<?php
error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');
$upload_handler = new UploadHandler();
?>
uploadHandler.php文件可以找到here
我将添加我修改的部分以上传到 S3
$bucket = "my bucket nmae";
$s3 = new S3(awsAccessKey, awsSecretKey);
$response = $s3->putObjectFile($file_path,$bucket,$file->name,S3::ACL_PUBLIC_READ);
$thumbResponse = $s3->putObjectFile('files/thumbnail/'.$file->name,$bucket,'images /'.$file->name,S3::ACL_PUBLIC_READ);
echo $response;
echo $thumbResponse;
if ($response==1) {
echo 'HERER enter!!';
} else {
$file->error = "<strong>Something went wrong while uploading your file... sorry.</strong>";
}
我没有上传太 大 文件,它在我的本地机器上运行良好,但在 beanstalk 上失败。任何帮助都会很棒。感谢您的关注。
【问题讨论】:
-
你的错误日志说什么?
-
检查服务器的错误日志。它将包含有关 500 的更多详细信息(除非您从亚马逊获得 500)。
-
我通过控制台配置了日志,但没有记录错误。 :(
-
我已经在下面的 cmets 中添加了日志信息。我在那里找不到问题!
标签: php jquery file-upload amazon-web-services amazon-s3