ajaxfileupload上传文件没反应 确认你的 js 部分与样例文件没有大的出入先检查文件确实非上传了exit(json_encode($_FILES)); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是不是js脚本有报错啊,你在firebug控制台下看有不有报错。 完全代码:上传文件表单upfileForm.php<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=gbk"><link href="../css/manager.css" rel="stylesheet" type="text/css" /><script type="text/javascript" src="../js/jquery.js"></script><script src="../js/ajaxfileupload.js" type="text/javascript"></script><script type="text/javascript" src="../js/jrosion.js"></script> <script type="text/javascript"> $(document).ready(function(){ }); function upload(){ $.ajaxFileUpload({ url: 'upfile.php', //用于文件上传的服务器端请求地址 secureuri: false, //是否需要安全协议,一般设置为false fileElementId: 'fileToUpload', //文件上传域的ID dataType: 'json', //返回值类型 一般设置为json success: function (data, status) //服务器成功响应处理函数 { alert(data.msg); //$("#img1").attr("src", data.imgurl); if (typeof (data.error) != 'undefined') { if (data.error != '') { alert(data.error); } else { alert(data.msg); } }else{ alert("upload file failure!"); } }, error: function (data, status, e)//服务器响应失败处理函数 { alert(e); } }); return true; } </script><title>网站栏目管理</title></head><body><!-- <form action="upfile.php" method="post" enctype="multipart/form-data"> --> <input type="file" id="fileToUpload" size="40" name="fileToUpload"> <button type="button" id="buttonUpload" onclick="return upload();">上传</button><!-- </form>--></body></html>上传文件服务端upfile.php<?phpheader("Content-type: text/html; charset=utf-8");$upFilePath = "../userUploadDatas/". $_SESSION ["userId"]."/";$res ["error"] = ""; // 错误信息$res ["msg"] = ""; // 提示信息if (@move_uploaded_file(@$_FILES ["fileToUpload"] ["tmp_name"], $upFilePath .@$_FILES ["fileToUpload"] ["name"])) { $res ["msg"] = "ok";} else { $res ["error"] = "error";}echo json_encode ( $res );死活不能AJAX上传啊, 直接<form action="upfile.php" method="post" enctype="multipart/form-data"> --> <input type="file" id="fileToUpload" size="40" name="fileToUpload"> <button type="button" id="buttonUpload" onclick="return upload();">上传</button></form>文件是可以上传的,我就不清楚了,我上面的代码怎么写才能AJAX上传文件,郁闷几天了,,不知道原因。。 先去掉<script type="text/javascript" src="../js/jrosion.js"></script>看看,可能有冲突 老大,已将jrosion.js去掉,效果一样。。 你在 upfile.php 中只写<?phpecho '{"msg":"hello"}';试试注意一定不要有 BOM 头 我受不了, 下载了一个错误的ajaxfileupload.js文件, 最后在CSDN下载了一个,没有问题, 我郁闷的不行,好像是在官网下载的。 求高手帮忙解决网站问题2 php数字循环,$a怎么写。 php源代码用什么工具看好,函数调用图,变量定义原始位置 MYSQL索引容量800多K,记录3万条,是不是太大了 session_start()报错 mysql 数据库!合并两个表(sql语句) thinkphp怎么把数据库的内容查询到页面上,并且添加操作按钮,怎么知道按钮点击的是哪一行的数据啊? 大家好!能帮我一下么?我是初学者! 很简单的但现在就是解决不了?怎么就连不上数据库呢 怎样在自画菜单中绘制渐变的颜色 100分求助PHP数组合并.... 关于XXX.php?id=,XXX.php中的变量id可用的条件是什么?
上传文件表单upfileForm.php<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"><link href="../css/manager.css" rel="stylesheet" type="text/css" /><script type="text/javascript" src="../js/jquery.js"></script>
<script src="../js/ajaxfileupload.js" type="text/javascript"></script>
<script type="text/javascript" src="../js/jrosion.js"></script> <script type="text/javascript">
$(document).ready(function(){
}); function upload(){
$.ajaxFileUpload({
url: 'upfile.php', //用于文件上传的服务器端请求地址
secureuri: false, //是否需要安全协议,一般设置为false
fileElementId: 'fileToUpload', //文件上传域的ID
dataType: 'json', //返回值类型 一般设置为json
success: function (data, status) //服务器成功响应处理函数
{
alert(data.msg);
//$("#img1").attr("src", data.imgurl);
if (typeof (data.error) != 'undefined') {
if (data.error != '') {
alert(data.error);
} else {
alert(data.msg);
}
}else{
alert("upload file failure!");
}
},
error: function (data, status, e)//服务器响应失败处理函数
{
alert(e);
}
});
return true;
}
</script><title>网站栏目管理</title>
</head>
<body><!-- <form action="upfile.php" method="post" enctype="multipart/form-data"> -->
<input type="file" id="fileToUpload" size="40" name="fileToUpload">
<button type="button" id="buttonUpload" onclick="return upload();">上传</button>
<!-- </form>--></body>
</html>上传文件服务端upfile.php<?phpheader("Content-type: text/html; charset=utf-8");$upFilePath = "../userUploadDatas/". $_SESSION ["userId"]."/";$res ["error"] = ""; // 错误信息
$res ["msg"] = ""; // 提示信息
if (@move_uploaded_file(@$_FILES ["fileToUpload"] ["tmp_name"], $upFilePath .@$_FILES ["fileToUpload"] ["name"])) {
$res ["msg"] = "ok";
} else {
$res ["error"] = "error";
}echo json_encode ( $res );
死活不能AJAX上传啊, 直接<form action="upfile.php" method="post" enctype="multipart/form-data"> -->
<input type="file" id="fileToUpload" size="40" name="fileToUpload">
<button type="button" id="buttonUpload" onclick="return upload();">上传</button>
</form>
文件是可以上传的,我就不清楚了,我上面的代码怎么写才能AJAX上传文件,郁闷几天了,,不知道原因。。
<script type="text/javascript" src="../js/jrosion.js"></script>
看看,可能有冲突
<?php
echo '{"msg":"hello"}';
试试
注意一定不要有 BOM 头