久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<small id='PTVch'></small><noframes id='PTVch'>

<tfoot id='PTVch'></tfoot>
      <i id='PTVch'><tr id='PTVch'><dt id='PTVch'><q id='PTVch'><span id='PTVch'><b id='PTVch'><form id='PTVch'><ins id='PTVch'></ins><ul id='PTVch'></ul><sub id='PTVch'></sub></form><legend id='PTVch'></legend><bdo id='PTVch'><pre id='PTVch'><center id='PTVch'></center></pre></bdo></b><th id='PTVch'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='PTVch'><tfoot id='PTVch'></tfoot><dl id='PTVch'><fieldset id='PTVch'></fieldset></dl></div>

      1. <legend id='PTVch'><style id='PTVch'><dir id='PTVch'><q id='PTVch'></q></dir></style></legend>

        • <bdo id='PTVch'></bdo><ul id='PTVch'></ul>

        xhr 發送 base64 字符串并在服務器中將其解碼為文

        xhr send base64 string and decode it in the server to a file(xhr 發送 base64 字符串并在服務器中將其解碼為文件)
        <legend id='1o29s'><style id='1o29s'><dir id='1o29s'><q id='1o29s'></q></dir></style></legend>
      2. <i id='1o29s'><tr id='1o29s'><dt id='1o29s'><q id='1o29s'><span id='1o29s'><b id='1o29s'><form id='1o29s'><ins id='1o29s'></ins><ul id='1o29s'></ul><sub id='1o29s'></sub></form><legend id='1o29s'></legend><bdo id='1o29s'><pre id='1o29s'><center id='1o29s'></center></pre></bdo></b><th id='1o29s'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='1o29s'><tfoot id='1o29s'></tfoot><dl id='1o29s'><fieldset id='1o29s'></fieldset></dl></div>

        1. <tfoot id='1o29s'></tfoot>

              <small id='1o29s'></small><noframes id='1o29s'>

              • <bdo id='1o29s'></bdo><ul id='1o29s'></ul>

                  <tbody id='1o29s'></tbody>

                  本文介紹了xhr 發送 base64 字符串并在服務器中將其解碼為文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述


                  我正在嘗試將 base64 編碼的 img 發送到服務器,javascript 看起來像


                  I am trying to to send a base64 encoded img to server,the javascript looks like

                  var xhr=new XMLHttpRequest()
                  var reader=new FileReader()
                  reader.onloadend=function(e){
                  xhr.onload=function(e){
                  alert(xhr.responseText)
                  }
                  xhr.open("POST","upload.php");
                          xhr.setRequestHeader("Cache-Control", "no-cache");
                          xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
                          //xhr.setRequestHeader("X-File-Name", file.name);
                          //xhr.setRequestHeader("X-File-Type",file.type)
                  xhr.send(e.target.result)
                  }
                  reader.readAsDataURL(file)
                  },false)
                  


                  在 php 中,如下所示:


                  In php,looks like this:

                  echo "some response Text";
                  $postdata = file_get_contents("php://input");
                  file_put_contents('MyFile.jpg', base64_decode($postdata));
                  

                  最后,服務器得到一個文件正好與發送的文件一樣大,但是無法打開
                  有人有一些想法嗎?非常感謝!

                  And,eventually,the server gets a file exactly as big as the sent file,However,it can't be opened
                  Some one get some ideas?Thanks a lot!

                  推薦答案

                  reader.readAsDataURL(file)
                  

                  數據 URL 與文件的 base64 版本不同.你會得到額外的垃圾.它看起來像這樣:

                  A data URL is NOT the same as a base64 version of the file. You get extra garbage in it. It looks like this:

                  data:[<MIME-type>][;charset=<encoding>][;base64],<data>
                  

                  參見維基百科.

                  嘗試對其做一個簡單的正則表達式:

                  Try doing a simple regex on it:

                  var data = dataURL.match(/,(.*)$/)[1];
                  

                  或者,在您的代碼中,

                  xhr.send(e.target.result.match(/,(.*)$/)[1]);
                  

                  這篇關于xhr 發送 base64 字符串并在服務器中將其解碼為文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)

                    <small id='xOVxy'></small><noframes id='xOVxy'>

                      <bdo id='xOVxy'></bdo><ul id='xOVxy'></ul>
                    • <tfoot id='xOVxy'></tfoot>
                    • <legend id='xOVxy'><style id='xOVxy'><dir id='xOVxy'><q id='xOVxy'></q></dir></style></legend>
                      <i id='xOVxy'><tr id='xOVxy'><dt id='xOVxy'><q id='xOVxy'><span id='xOVxy'><b id='xOVxy'><form id='xOVxy'><ins id='xOVxy'></ins><ul id='xOVxy'></ul><sub id='xOVxy'></sub></form><legend id='xOVxy'></legend><bdo id='xOVxy'><pre id='xOVxy'><center id='xOVxy'></center></pre></bdo></b><th id='xOVxy'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xOVxy'><tfoot id='xOVxy'></tfoot><dl id='xOVxy'><fieldset id='xOVxy'></fieldset></dl></div>

                          <tbody id='xOVxy'></tbody>

                          1. 主站蜘蛛池模板: 精品国产一区二区在线观看 | 酒色成人网 | 麻豆精品久久 | 1级黄色大片 | 亚洲免费精品视频 | 新香蕉视频 | 欧美成人猛片aaaaaaa | 黄视频在线播放 | 久久久久久久国产 | 成人在线不卡 | 欧美一级淫片免费视频魅影视频 | 日韩av专区 | 日韩久久久久 | 在线观看黄色片 | 免费在线观看黄 | av片在线看 | 综合久久99| 久久久影院 | 日韩精品视频在线播放 | 最近日本中文字幕 | 中文字幕av一区二区三区 | 久久久久久久国产精品 | 激情91| 在线视频a | av色婷婷| 欧美视频a| 日本国产一区 | 91婷婷 | 黄色小视频免费观看 | 亚洲永久免费视频 | 国产成人免费观看 | aaa黄色片| 精品网站999www | 国产一区久久 | 四虎影院永久免费 | 亚洲国产欧美在线 | 欧美在线一区二区三区 | 天天干天天操天天爽 | 日韩视频在线播放 | 亚洲成人精品视频 | 久久网av|