jQuery上传问题

时间:2015-03-10 09:22:52

标签: php jquery

我上一个问题的一个非常了不起的用户给了我一段似乎在他的结尾工作的代码......虽然不是很重要。

以下是代码:

$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内部服务器错误。任何人都知道为什么?

请查看以下链接:

http://i.gyazo.com/6145dff8581633318c69ea3713b1112e.png

0 个答案:

没有答案