android访问自己写的页面出现code500错误是怎么回事呢?
By q191045643
at 2016-08-09
0人收藏 • 1797人看过
我在我写的页面加上插入upload表的代码后,android访问会出现code500,如果注释掉的话就正常返回json信息,可是我在common.php里没有找到显示code500错误的代码,不知道什么原因,插入upload表代码如下:(注释处会引起500错误)
do{
$stateInfo="";
$file=$_FILES['uploadedfile'];
if (!$file) {
$stateInfo ="ERROR_FILE_NOT_FOUND";
break;
}
if ($file['error']) {
$stateInfo = "error";
break;
} else if (!file_exists($file['tmp_name'])) {
$stateInfo = "ERROR_TMP_FILE_NOT_FOUND";
break;
} else if (!is_uploaded_file($file['tmp_name'])) {
$stateInfo = "ERROR_TMPFILE";
break;
}
$oriName= $file['name'];
$fileSize = $file['size'];
$fileLongType = $file['type'];
$fileType = strtolower(strrchr($oriName, '.'));
$fullName = $file['name'];
$filePath = "./upload/doctorfile/".$DBUser['ID']."/";
$fileName = $file['name'];
$dirname = "./upload/doctorfile/".$DBUser['ID']."/";
if($fileSize > 10240000){
$stateInfo = "ERROR_SIZE_EXCEED";
break;
}
$target_path = "./upload/doctorfile/".$DBUser['ID']."/";//接收文件目录
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$SHA1=sha1_file($_FILES['uploadedfile']['tmp_name']);
$MD5=md5_file($_FILES['uploadedfile']['tmp_name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
//移动成功
$stateInfo = "SUCCESS";
/*
$DB->query('INSERT INTO ' . $this->Prefix . 'upload(`UserName`, `FileName`, `FileSize`, `FileType`, `SHA1`, `MD5`, `FilePath`, `Description`, `Category`, `Class`, `PostID`, `Created`) VALUES(:UserName, :FileName, :FileSize, :FileType, :SHA1, :MD5, :FilePath, :Description, :Category, :Class, :PostID, :Created)', array(
'UserName' => $UploadUserName,
'FileName' => htmlspecialchars($oriName),
'FileSize' => $fileSize,
'FileType' => $fileLongType,
'SHA1' => $SHA1,
'MD5' => $MD5,
'FilePath' => $filePath,
'Description' => '',
'Category' => '',
'Class' => 'Forum',
'PostID' => 0,
'Created' => time()
));
*/
} else{
//移动失败
$stateInfo = "ERROR_FILE_MOVE";
}
}while(false);
- 登录后方可回帖
回复 #1 @q191045643 :
500是代码错误,系统发出的。
回复#2 @lincanbin :
是php的插入数据库语句有错吗,我是按照你那个uploadfile.php写的,不应该啊
回复#2 @lincanbin :
谢谢了,已经解决了