Ajax图像上传403错误

时间:2015-05-15 12:47:31

标签: php jquery ajax

我在我的网站上实施了summernote,并尝试使用ajax调用来处理图片上传。我正在使用的代码我从另一个stackoverflow帖子中获取并且它适用于其他人,我只更改了URL。但是我收到以下错误:

GET http://intranet-dev/Dev/Rehan/ProjectTracker/%3Cbr%20/%3E%3Cb%3EParse%20err…te_doc_upload_post.php%3C/b%3E%20on%20line%20%3Cb%3E23%3C/b%3E%3Cbr%20/%3E 403 (Forbidden)

summernote使用了这个:

        onImageUpload: function(files, editor, welEditable) {
        sendFile(files[0], editor, welEditable);
        }

然后sendfile函数进行ajax调用:

function sendFile(file, editor, welEditable) {
    data = new FormData();
    data.append("file", file);
            $.ajax({
                data: data,
                type: "POST",
                //url: "/Dev/Rehan/ProjectTracker/form_summernote_doc_upload_post.php",
                 url: "form_summernote_doc_upload_post.php",
                cache: false,
                contentType: false,
                processData: false,
                success: function(url) {
                    editor.insertImage(welEditable, url);
                }
            });
}
发布它的php看起来像这样:

if ($_FILES['file']['name']) {
        if (!$_FILES['file']['error']) {
            $name = md5(rand(100, 200));
            $ext = explode('.', $_FILES['file']['name']);
            $filename = $name . '.' . $ext[1];
            $destination = '/uploads/document/summernote/' //change this directory
            $location = $_FILES["file"]["tmp_name"];
            move_uploaded_file($location, $destination);
            echo 'http://intranet-dev/Dev/Rehan/ProjectTracker/uploads/document/summernote/'.$filename;//change this URL

        }
        else
        {
          echo  $message = 'Ooops!  Your upload triggered the following error:  '.$_FILES['file']['error'];
        }
    }

0 个答案:

没有答案