久久久久久久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 發(fā)送 base64 字符串并在服務(wù)器中將其解碼為文

        xhr send base64 string and decode it in the server to a file(xhr 發(fā)送 base64 字符串并在服務(wù)器中將其解碼為文件)
        <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 發(fā)送 base64 字符串并在服務(wù)器中將其解碼為文件的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述


                  我正在嘗試將 base64 編碼的 img 發(fā)送到服務(wù)器,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));
                  

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

                  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)
                  

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

                  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>
                  

                  參見維基百科.

                  嘗試對(duì)其做一個(gè)簡(jiǎn)單的正則表達(dá)式:

                  Try doing a simple regex on it:

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

                  或者,在您的代碼中,

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

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

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

                  相關(guān)文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會(huì)等待 ajax 調(diào)用完成)
                  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 無法加載,請(qǐng)求的資源上不存在“Access-Control-Allow-Origin標(biāo)頭) - IT屋-程序員軟件開發(fā)技術(shù)分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請(qǐng)求是否有可能不遵循重定向 (301 302))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)

                    <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. 主站蜘蛛池模板: 国产精品欧美一区二区三区不卡 | h视频免费在线观看 | 国产日韩欧美一区 | 久久精品亚洲一区 | 国产欧美日韩在线观看 | 91精品国产99久久 | 日韩在线不卡视频 | 日本精品视频在线 | 拍拍无遮挡人做人爱视频免费观看 | 在线中文字幕日韩 | 欧美一区二区三区视频 | 亚洲一区二区在线视频 | 国产三区在线观看视频 | 久久久久久免费观看 | 天天干狠狠操 | 国产精品视频久久 | 成人精品一区二区三区 | 最新免费黄色网址 | 日本高清在线一区 | 国产乱码精品一区二区三区中文 | 久久99深爱久久99精品 | www.亚洲一区 | 一区二区av | 欧美一级片在线观看 | 欧美成人精品一区二区男人看 | 日本久久一区 | 久久国产精品72免费观看 | 欧美一级艳情片免费观看 | 国产成人精品久久二区二区91 | 成人av片在线观看 | 狠狠伊人 | 99精品亚洲国产精品久久不卡 | 夜久久| 中文字幕av一区二区三区 | 一级黄色日本片 | 日本高清视频在线播放 | h片在线观看免费 | 国产精品高潮呻吟久久久久 | 中文字幕视频在线观看 | 网站国产 | 精品永久 |