<head>
<ti
<sc
<sc
</head>
<body>
<input type=”file” name=”file1″ id=”file1″/>
<button type=”button” id=”submitId”>点击上传</button>
<sc
$(“#submitId”).on(“click”,function () {
$.ajaxFileUpload({
url:”{:U(‘Upload/yes’)}”, //你处理上传文件的服务端
secureuri:false,//是否启用安全机制
fileElementId:’file1′,//file的id
dataType: ‘application/json’,//返回的类型
success: function (data) {
alert(“上传成功”);
}
});
})
</sc
</body>
</html>
<?php
namespace Home\Controller;
use Think\Controller;
class UploadController extends Controller {
public function index(){
$this->display();
}
public function yes(){
if($_FILES){
echo 1;
}else{
echo 2;
}
}
}
文件下载地址:http://www.momoyingyu.com/blog/archives/401
最佳答案