ajaxfileupload上传文件没反应解决方案

WBOY
Release: 2016-06-13 12:03:57
Original
1389 people have browsed it

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 />
Copy after login


<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 />
Copy after login


upfile.php
<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 />
Copy after login


无法上传文件,不知道什么地方有问题。。。希望大侠指点
------解决方案--------------------
确认你的 js 部分与样例文件没有大的出入

先检查文件确实非上传了
exit(json_encode($_FILES));
------解决方案--------------------
是不是js脚本有报错啊,你在firebug控制台下看有不有报错。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template