Heim > Artikel > Backend-Entwicklung > ajaxfileupload上传文件没反应解决方案
ajaxfileupload上传文件没反应
<br /> function ajaxFileUpload(){<br /> $.ajaxFileUpload ({<br /> url:'upfile.php',<br /> secureuri:false,<br /> fileElementId:'pic',<br /> dataType: 'json',<br /> success : function (data, status){<br /> if(typeof(data.error) != 'undefined'){<br /> if(data.error != ''){<br /> alert(data.error);<br /> }else{<br /> alert(data.msg);<br /> }<br /> }<br /> },<br /> error: function(data, status, e){<br /> alert(e);<br /> }<br /> }) <br /> return false;<br /> }<br />
<br /><A class=btn_addPic><SPAN><EM>+</EM>添加图片</SPAN> <INPUT class=filePrew type=file size=3 name='pic' id='pic'></A><input type='button' value='上传' class='upbt' onclick='return ajaxFileUpload();' ><br />
<br />$upFilePath = "../userUploadDatas/" . $_SESSION ["userId"] . "/";<br /><br />$res ["error"] = ""; // 错误信息<br />$res ["msg"] = "exec"; // 提示信息<br />if (copy ( $_FILES ['pic'] ['tmp_name'], $upFilePath . $_FILES ['pic'] ['name'] )) {<br /> $res ["msg"] = "ok";<br />} else {<br /> $res ["error"] = "error";<br />}<br /><br />echo json_encode ( $res );<br />