时间:2021-07-01 10:21:17 帮助过:13人阅读
function ajaxFileUpload(){
$.ajaxFileUpload ({
url:'upfile.php',
secureuri:false,
fileElementId:'pic',
dataType: 'json',
success : function (data, status){
if(typeof(data.error) != 'undefined'){
if(data.error != ''){
alert(data.error);
}else{
alert(data.msg);
}
}
},
error: function(data, status, e){
alert(e);
}
})
return false;
}
+添加图片
$upFilePath = "../userUploadDatas/" . $_SESSION ["userId"] . "/";
$res ["error"] = ""; // 错误信息
$res ["msg"] = "exec"; // 提示信息
if (copy ( $_FILES ['pic'] ['tmp_name'], $upFilePath . $_FILES ['pic'] ['name'] )) {
$res ["msg"] = "ok";
} else {
$res ["error"] = "error";
}
echo json_encode ( $res );