我正在使用此HTML表单上传图片:
<form id="uploader_frm" method="post"
action="http://www.example.com/Admin/saveContentinplace.php?action=uploadPhoto"
onsubmit="return AIM.submit(this, {'onStart' : startCallback, 'onComplete' : completeCallback})"
enctype="multipart/form-data">
<div align="right">
<label>Pic</label>
<input type="file" class="ENTextbox" name="photo" id="photo" style="width:295px;">
</div>
<br><br>
<div align="center">
<input type="submit" value="Upload" class="button">
<input type="button" onclick="AddNewPic();document.location.reload();" value="Finish" class="button">
</div>
<input type="hidden" value="" name="itemID" id="itemID">
</form>
这是处理上传的javascript函数:
AIM = {
frame : function(c) {
var n = 'f' + Math.floor(Math.random() * 99999);
var d = document.createElement('DIV');
d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+n+'" name="'+n+'" onload="AIM.loaded(\''+n+'\')"></iframe>';
document.body.appendChild(d);
var i = document.getElementById(n);
if (c && typeof(c.onComplete) == 'function') {
i.onComplete = c.onComplete;
}
return n;
},
form : function(f, name) {
f.setAttribute('target', name);
},
submit : function(f, c) {
AIM.form(f, AIM.frame(c));
if (c && typeof(c.onStart) == 'function') {
return c.onStart();
} else {
return true;
}
},
loaded : function(id) {
var i = document.getElementById(id);
if (i.contentDocument) {
var d = i.contentDocument;
} else if (i.contentWindow) {
var d = i.contentWindow.document;
} else {
var d = window.frames[id].document;
}
if (d.location.href == "about:blank") {
return;
}
if (typeof(i.onComplete) == 'function') {
i.onComplete(d.body.innerHTML);
}
}
}
问题在于,当我提交表单时,我收到“未选择文件”且图片未上传。
服务器:运行apache 2.4.9和php 5.4.30
的Cenos 6.5