我上一个问题的一个非常了不起的用户给了我一段似乎在他的结尾工作的代码......虽然不是很重要。
以下是代码:
$json = array('code' => 200, 'msg' => "Avatar uploaded!");
//if a file was submitted
if($_FILES)
{
try
{
$filename = md5(time() . rand(0, 1000));
$result = $bulletproof->fileTypes(["png", "jpeg"])
->uploadDir("uploads")
->limitSize(["min" => 1000, "max" => 300000])
->shrink(["height" => 96, "width" => 96])
->upload($_FILES['image_file'], $filename);
print_r(json_encode($json));
}
catch(Exception $e)
{
$json['code'] = 500;
$json['msg'] = $e->getMessage();
print_r(json_encode($json));
}
}
else
{
//no file was submitted
//send back a 500 error code and a error message
$json['code'] = 500;
$json['msg'] = "You must select a file";
print_r(json_encode($json));
}
因此,当我使用图像提交数据时,它会发送POST请求,但会返回500内部服务器错误。任何人都知道为什么?
请查看以下链接: