我正在尝试使用uploadify将其文件发送到php脚本,但每次都会返回空白...我完全感到困惑,因为有时它甚至不会尝试上传文件。
形式:
<form action="upload.php?1" method="post" id="uploadForm" enctype="multipart/form-data">
<input type='file' name='uploadBox' id='uploadBox' /><br/>
<input class="button" type="submit" value="{Upload}" />
<script type="text/javascript">
// makes the flash uploader work
$(document).ready(function(){
$('#uploadBox').uploadify ({
'uploader' : 'uploader.swf?PHPSESSID=4aa17bc8a50f8265ee27ec5fb469d7e5',
'script' : 'upload.ajax.php?PHPSESSID=4aa17bc8a50f8265ee27ec5fb469d7e5',
'cancelImg' : 'cancel.png',
'auto' : false,
'sizeLimit' : '8388608',
'buttonText' : "Browse",
'multi' : true,
'fileExt' : "*.jpg;*.jpeg;*.png",
'scriptData': {'album':"1", "session":"4aa17bc8a50f8265ee27ec5fb469d7e5"},
onError : function(event, queueID, fileObj, errorObj){ alert("ERROR"); console.log(errorObj); }
});
$("#uploadForm .button").click(function(){
$("#uploadBox").uploadifyUpload();
console.log("uploading...");
return false;
});
console.log("attached");
});
</script>
</form>
这是upload.ajax.php文件: 注意事项:它需要会话才能使其工作,add_to_album会完成所有缩略图工作和内容
<?php
// upload photos via background flash thingy mobob
include "../../functions.php"; start($_REQUEST['PHPSESSID']);
include "../../inc/photo.php";
// we need to upload this file we've got to the normal stuff we use :D
if(!is_logged_in()){
echo "0";
exit;
}
$fail = false;
foreach($_FILES as $file){
if(add_to_album($file['tmp_name'], $_REQUEST['album']) == false)
$fail = true;
}
echo "upload has finished";
if($fail == true)
echo "0";
else
echo "1";
答案 0 :(得分:0)
什么是foreach?如果输入文件名称为uploadBox,则检查$ _FILES ['uploadBox'] ['tmp_name']。
答案 1 :(得分:0)
AHA!刚刚意识到它的主要问题。 start()函数正在寻找语言,失败并告诉脚本死...所以它不起作用
BAM!一切都亮了,它起作用了:D
YAY:D