function sendPhoto()
{
var time = vaxt(new Date());
$(".mes-all").append("<div class=\"mes-my\"><span class=\"mes-targering\"><span class=\"foto\"><i class=\"fa fa-circle-o-notch fa-spin\" style=\"font-size:30px;color:black\"></i></span></span><span style=\"display:inline\" class=\"mes-my-tr\">"+time+" <i class=\"fa fa-spinner fa-spin\" style=\"margin-left: 4px;\"></i></span></div>");
scroll();
var fd = new FormData();
fd.append( "file", $(".mes-sending-photo")[0].files[0]);
fd.append( "to",$(".id").val());
$.ajax({
url: "ajax/sendPhoto.php",
data: fd,
processData: false,
contentType: false,
type: "POST",
success: function(){
getMessage();
}
});
}
我认为问题出在服务器端而不是代码上,但我也找不到。错误响应:远程地址:46.17.40.62:80
请求 URL:http ://masters.az/ajax/sendPhoto.php
请求方法:POST 状态代码:500 Internal Server Error Request Headersview parsed POST /ajax/sendPhoto.php HTTP/ 1.1 主机:masters.az 连接:keep-alive 内容长度:159591 接受:/
来源:http ://masters.az
X-Requested-With:XMLHttpRequest 用户代理:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit /537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36 Content-Type: multipart/form-data; 边界=----
WebKitFormBoundaryB8Wq6VD8CcBe7y9A 引用:http
://masters.az/message-4
Accept-Encoding: gzip,deflate
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
Cookie: login=fuad; 言语=12345;身份证=2;cuid=Mw%3D%3D;
杯子=ac4b3abea4ff5ffb14f92d05d18f3c68;登录=fuad;言语=12345;身份证=2;
session=P7ytO93YItgRjUerd5PgJmrO5gN7KIrjPpdlweIDVyeFRG44LTkeDa0IGONagEI4
请求负载
------WebKitFormBoundaryB8Wq6VD8CcBe7y9A
内容处置:表单数据;名称=“文件”;文件名="logo.jpg"
内容类型:图片/jpeg
------WebKitFormBoundaryB8Wq6VD8CcBe7y9A
内容处置:表单数据;名称=“到”
4
------WebKitFormBoundaryB8Wq6VD8CcBe7y9A--
Response Headersview source
Connection:close
Content-Length:594
Content-Type:text/html
Date:Thu, 04 Feb 2016 16:40:13 GMT
Server:nginx/1.6.2
php代码是(通过ajax发送的内容):
<?php
if($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
ini_set('display_errors', 1);
error_reporting(E_ALL);
require("../inc/core.php");
$file=$_FILES['file'];
$tip=$file['type'];
$size=$file['size'];
$t=time();
$yer="../files/mes_images/".$t."_big.png";
$access_size=5*(1000000);
$access_type=array("image/gif","image/jpg","image/jpeg","image/pjpeg","image/x-png","image/png");
if(in_array($tip,$access_type) && $size<=$access_size && !empty($file['name'])){
$q=move_uploaded_file($file['tmp_name'],$yer);
echo $q?"ok":"no";
resize($yer,null,100,100,false,"../files/mes_images/".$t.".png",false,false,100);
$mes="[img]../files/mes_images/".$t.".png[/img]";
$to=$_POST['to'];
$block=leo::mfa("select * from blok where (`by`='$usid' && `to`='$to') || (`by`='$to' && `to`='$usid') ");
if(!$block){
$check=leo::mfa("select * from `mail` where (`by`='$usid' && `to`='$to') || (`by`='$to' && `to`='$usid') ");
if($check){
$cid=$check['cid'];
}else{
$scid=leo::mfa("select * from `mail` order by cid desc limit 1");
$cid=$scid?$scid['cid']+1:1;
}
$qu=leo::mq("insert into `mail` set `by`='$usid',`to`='$to',mesaj='$mes',vaxt='".time()."',oxu='yox',cid='$cid'");
}
}
}else{
header("location:../err?err=303");
}
?>