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

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

    <bdo id='onqBy'></bdo><ul id='onqBy'></ul>

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

      使用沒有 FormData (IE9) 的 AJAX 上傳文件

      Uploading files using AJAX without FormData (IE9)(使用沒有 FormData (IE9) 的 AJAX 上傳文件)
    3. <i id='DeDWx'><tr id='DeDWx'><dt id='DeDWx'><q id='DeDWx'><span id='DeDWx'><b id='DeDWx'><form id='DeDWx'><ins id='DeDWx'></ins><ul id='DeDWx'></ul><sub id='DeDWx'></sub></form><legend id='DeDWx'></legend><bdo id='DeDWx'><pre id='DeDWx'><center id='DeDWx'></center></pre></bdo></b><th id='DeDWx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='DeDWx'><tfoot id='DeDWx'></tfoot><dl id='DeDWx'><fieldset id='DeDWx'></fieldset></dl></div>
        <tbody id='DeDWx'></tbody>

        <tfoot id='DeDWx'></tfoot>

            1. <small id='DeDWx'></small><noframes id='DeDWx'>

            2. <legend id='DeDWx'><style id='DeDWx'><dir id='DeDWx'><q id='DeDWx'></q></dir></style></legend>

              • <bdo id='DeDWx'></bdo><ul id='DeDWx'></ul>
                本文介紹了使用沒有 FormData (IE9) 的 AJAX 上傳文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                在 IE9 中,不支持 FormData,這使得使用 XMLHttpRequest 上傳文件變得不那么簡單了.

                In IE9, FormData is not supported, which makes uploading files using XMLHttpRequest a lot less trivial.

                這可以嗎?我已經看到提到的 iFrame,雖然我不反對編寫一些毛茸茸的代碼,但我不知道如何實現這一點(有很多資源談論上傳到 iFrame,但沒有關于如何獲取文件從 iFrame 到服務器).

                Can this be done? I've seen iFrames mentioned, and while I'm not opposed to writing some hairy code, I'm at a loss as to how to achieve this (there are many resources talking about uploading to an iFrame but not about how to get the file from the iFrame to the server).

                使用 vanilla JavaScript(沒有第三方庫),如何在不使用 FormData 的情況下異步上傳文件?

                Using vanilla JavaScript (no third party libraries), how would one upload a file asynchronously without the use of FormData?

                推薦答案

                這段代碼應該可以解決問題.抱歉很久以前,我認為 IE9 也可以使用 XHR 上傳(應該,但這是 Iframe 選項).

                This code should do the trick. Sorry was a long time ago and I thought that IE9 also could upload using XHR (It should, but this is the Iframe option).

                它執行以下操作:

                1. 向您的頁面添加文件輸入(也可以在 HTML 中完成)
                2. 將該文件選擇器放入表單中
                3. 向表單添加憑據
                4. 將表單提交到 iframe 并將其頁面用作返回值.

                fileSelection  = document.createElement("div");
                //create the file input
                fileSelection.browseSelect = document.createElement("input");
                fileSelection.browseSelect.type = "file";
                fileSelection.browseSelect.name = "file[]";
                fileSelection.browseSelect.style.display = "block";
                fileSelection.browseSelect.style.position = "absolute";
                fileSelection.browseSelect.style.left = "50%";
                fileSelection.browseSelect.style.top = "auto";
                fileSelection.browseSelect.style.height = "36px";
                fileSelection.browseSelect.style.width = "36px";
                fileSelection.browseSelect.style.bottom = "0px";
                fileSelection.browseSelect.style.margin = "0px 0px -1px 90px";  
                fileSelection.browseSelect.style.filter = "alpha(opacity=0)";
                fileSelection.browseSelect.style.zIndex = 14;
                
                //Put a form in it.
                fileSelection.form = document.createElement("form");
                fileSelection.form.method = "POST";
                fileSelection.form.action = [url to server]; //put your own file upload handler here. 
                fileSelection.form.enctype = "multipart/form-data";
                fileSelection.form.encoding = "multipart/form-data";
                fileSelection.appendChild(fileSelection.form);
                //Append the file input to the form.
                fileSelection.form.appendChild(fileSelection.browseSelect);
                
                document.body.appendChild(fileSelection);
                
                function doUploadObjectUpload()
                {
                    var tempFrame = document.createElement("iframe");
                    tempFrame.src = "";
                    tempFrame.allowTransparancy = "true";
                    tempFrame.style.display = "none";
                    tempFrame.frameBorder = 0;
                    tempFrame.style.backgroundColor = "transparent";
                    tempFrame.onload = followUpOnHTML4Upload.bind(this,tempFrame);
                
                    tempFrame.name = "tmpFrameUpload"
                    this.appendChild(tempFrame);
                    this.form.target = tempFrame.name;
                    this.form.name = "uploadForm";
                    this.form.acceptCharset = "UTF-8"
                
                    //This is an example of a hidden input, used to pass extra vars to the server. Add more if you need them.
                    var tempNodePath = document.createElement("input");
                    tempNodePath.type = "hidden";
                    tempNodePath.value = [dir]; //if you want specify a target path.
                    tempNodePath.name = "filePath";
                    this.form.insertBefore(tempNodePath, this.form.childNodes[0]);
                
                    this.form.submit();
                }
                
                function followUpOnHTML4Upload(frameId)
                {
                        //Here you can check the response that came back from the page.
                }
                

                例如 PHP 會將文件存儲在 $_FILES

                PHP for example will store the files in $_FILES

                這篇關于使用沒有 FormData (IE9) 的 AJAX 上傳文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 部分內容)
                1. <i id='sAOdl'><tr id='sAOdl'><dt id='sAOdl'><q id='sAOdl'><span id='sAOdl'><b id='sAOdl'><form id='sAOdl'><ins id='sAOdl'></ins><ul id='sAOdl'></ul><sub id='sAOdl'></sub></form><legend id='sAOdl'></legend><bdo id='sAOdl'><pre id='sAOdl'><center id='sAOdl'></center></pre></bdo></b><th id='sAOdl'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='sAOdl'><tfoot id='sAOdl'></tfoot><dl id='sAOdl'><fieldset id='sAOdl'></fieldset></dl></div>

                  • <small id='sAOdl'></small><noframes id='sAOdl'>

                      <bdo id='sAOdl'></bdo><ul id='sAOdl'></ul>

                          <legend id='sAOdl'><style id='sAOdl'><dir id='sAOdl'><q id='sAOdl'></q></dir></style></legend>

                          <tfoot id='sAOdl'></tfoot>
                            <tbody id='sAOdl'></tbody>
                          主站蜘蛛池模板: 亚洲高清久久 | 免费黄色大片 | 欧美一区二区三区视频 | 久久国产精品一区二区三区 | 精品欧美乱码久久久久久1区2区 | 欧美黄a | 欧美精品一区二区三区在线播放 | www.亚洲精品| 亚洲精品免费在线观看 | 美女国产精品 | 亚洲精品电影网在线观看 | 91在线视频免费观看 | 久久久久久久久久久久91 | 91色视频在线观看 | 亚洲国产成人精品久久 | 欧美mv日韩mv国产网站91进入 | 综合激情网 | 波多野结衣中文字幕一区二区三区 | 国产精品国产三级国产aⅴ中文 | 日本一区二区在线视频 | 国产一区二区在线免费观看 | 欧美成人激情 | 久色视频在线 | 日韩免费av| 美女爽到呻吟久久久久 | 成人免费观看男女羞羞视频 | 午夜小影院 | 福利视频日韩 | 91大片| 99reav| 欧美涩涩网| 怡红院怡春院一级毛片 | 日韩中文在线观看 | 羞羞免费网站 | 在线观看中文字幕亚洲 | 亚洲精品在线免费播放 | 国产精品久久久久久久久久久久 | 在线视频一区二区三区 | 欧美综合国产精品久久丁香 | 91精品无人区卡一卡二卡三 | 伊人91在线 |