ajax上传⽂件报错500,JQuery的AJAX⽂件上传错误500所以我试图做使⽤jQuery的AJAX的东西⽂件上传,并不断给我500JQuery的AJAX⽂件上传错误500
$(function() {
$('form').submit
(
function()
{
$.ajax({
type: 'POST',
url: 'photochallenge/submit.php',
data: new FormData(this),
processData: false,
contentType: false,
success: function(data) {
}
免费源码php网});
return false;
}
);
});db browser
我也是⽤这个PHP代码来处理错误⽂件上传:
$target_dir = "uploads/";
java vector$target_file = null;
$uploadOk = 1;
$response = "Please choose an image";
// Check if image file is a actual image or fake image
if(isset($_POST["pic"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
$uploadOk = 1;
} else {
$response = "File is not an image.";
$uploadOk = 0;
}
// Check file size
if ($uploadOk == 1 && $_FILES["fileToUpload"]["size"] > 500000) {
霹雳天越下一部$response = "Sorry, your file is too large.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
// if everything is ok, try to upload file
} else {
//find target file
$found = false
$tmp = 0
while(!$found) {
$target_file = $target_dir . $tmp . ".png";
5转换成二进制if(file_exists($target_file)) {
$tmp = $tmp + 1;
jquery下载文件进度条} else {
$found = true;
}
}
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
$response = "Thank you for your submission!";
shell_exec("python log.py ".$_POST["firstname"]." ".$_POST["lastname"]." ".$target_file);
} else {
$response = "Sorry, there was an error uploading your file.";
}
}
}
echo $response;
?>
不幸的是,我不能释放链接到实际的问题出在哪⾥,但希望这个代码是不⾜以帮助解决问题。如果需要其他细节,请不要犹豫,让我知道。+0
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论