通过xhr发送二进制数据时出错403

时间:2013-10-31 15:54:46

标签: php apache xmlhttprequest lampp

我尝试使用Xhr sendAsBinary将二进制数据发送到服务器。当我从localhost测试它时它没有任何故障。但是当它从我的共享主机服务器测试时,我得到了这个回复

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /mvc/control/upload.php
on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>

它从同一个域发送请求,当我检查错误日志时,我得到以下

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/timezonedb.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20090626/timezonedb.so: cannot open shared object file: No such file or directory in Unknown on line 0

我想也许问题是我的php文件所以使用另一个url到另一个文件,它给了我同样的错误,我甚至尝试输入不存在的文件路径,它只是给了我同样的错误。 我的js看起来像这样

function upload(file,json_content,callback,prog,path)
{
var reader = new FileReader();
reader.readAsBinaryString(file); // alternatively you can use readAsDataURL
var jc = JSON.stringify(json_content);// turning the json object to a string so that it be written to array buffer as binary
var jc_size = jc.length;//the length of the stringified json object
reader.onload  = function(evt)
{
    xhr = new XMLHttpRequest();
    // send the file through POST
    xhr.open("POST", path, true);
    // make sure we have the sendAsBinary method on all browsers
    XMLHttpRequest.prototype.mySendAsBinary = function(text)
    {
        var f_size = text.length;
        var data = new ArrayBuffer(f_size+4+jc_size); //the length of the file plus the 1 byte code
        var ui32a = new Uint32Array(data,0,1);
        var ui8a = new Uint8Array(data,4,f_size);
        var ui8_jsn = new Uint8Array(data,4+f_size,jc_size);
        ui32a[0] = (f_size)& 0xffffffff;
        var test = new Uint8Array(data,0,4);

        for (var i = 0; i < f_size; i++) 
        {
            ui8a[i] = (text.charCodeAt(i) & 0xff);
        }
        for (var i = 0; i < jc_size; i++) 
        {
            ui8_jsn[i] = (jc.charCodeAt(i) & 0xff);
        }
        if(typeof window.Blob == "function")
        {
            var blob = new Blob([data]);
        }else
        {
            var bb = new (window.MozBlobBuilder || window.WebKitBlobBuilder || window.BlobBuilder)();
            bb.append(data);
            var blob = bb.getBlob();
        }

    this.send(blob);
    }
    if(prog !== false) /*if progress is needed*/
    {
        // tracking upload progress
         var eventSource = xhr.upload || xhr;
         eventSource.addEventListener("progress", function(e)
         {
         // get percentage of how much of the current file has been sent
         var position = e.position || e.loaded;
         var total = e.totalSize || e.total;
         progress = "#" + prog;
         $(progress).attr('max', total);
                        var percentage = Math.round((position/total)*100);

                        $(progress).css('width', percentage+"%").html(percentage+"%");
          });
     }

     // state change observer - after successfull upload..thentyu
     xhr.onreadystatechange = function()
      {
          if(xhr.readyState == 4)
          {

            if(xhr.status == 200)
            {

                callback(xhr.response);                                 

            }else{
                                // process error
                 }
             }
         };

                    // start sending
        xhr.mySendAsBinary(evt.target.result);
            };
        }

任何帮助将不胜感激,我尝试联系webhost,但他们似乎无能为力

0 个答案:

没有答案