pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<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="g0i2es2" 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="yg0wyuq" 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="iqyy0uk" 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>
                          主站蜘蛛池模板: 网站建设,北京网站建设,北京网站建设公司,网站系统开发,北京网站制作公司,响应式网站,做网站公司,海淀做网站,朝阳做网站,昌平做网站,建站公司 | 东莞办公家具厂家直销-美鑫【免费3D效果图】全国办公桌/会议桌定制 | sfp光模块,高速万兆光模块工厂-性价比更高的光纤模块制造商-武汉恒泰通 | 没斑啦-专业的祛斑美白嫩肤知识网站-去斑经验分享 | Honsberg流量计-Greisinger真空表-气压计-上海欧臻机电设备有限公司 | 北京开业庆典策划-年会活动策划公司-舞龙舞狮团大鼓表演-北京盛乾龙狮鼓乐礼仪庆典策划公司 | Copeland/谷轮压缩机,谷轮半封闭压缩机,谷轮涡旋压缩机,型号规格,技术参数,尺寸图片,价格经销商 CTP磁天平|小电容测量仪|阴阳极极化_双液系沸点测定仪|dsj电渗实验装置-南京桑力电子设备厂 | 陕西华春网络科技股份有限公司 | 浙江华锤电器有限公司_地磅称重设备_防作弊地磅_浙江地磅售后维修_无人值守扫码过磅系统_浙江源头地磅厂家_浙江工厂直营地磅 | 品牌设计_VI设计_电影海报设计_包装设计_LOGO设计-Bacross新越品牌顾问 | 真石漆,山东真石漆,真石漆厂家,真石漆价格-山东新佳涂料有限公司 | 深圳离婚律师咨询「在线免费」华荣深圳婚姻律师事务所专办离婚纠纷案件 | 衬塑管道_衬四氟管道厂家-淄博恒固化工设备有限公司 | 政府园区专业委托招商平台_助力企业选址项目快速落地_东方龙商务集团 | 烟雾净化器-滤筒除尘器-防爆除尘器-除尘器厂家-东莞执信环保科技有限公司 | 北京开源多邦科技发展有限公司官网 | 水性绝缘漆_凡立水_绝缘漆树脂_环保绝缘漆-深圳维特利环保材料有限公司 | 紫外荧光硫分析仪-硫含量分析仪-红外光度测定仪-泰州美旭仪器 | ICP备案查询_APP备案查询_小程序备案查询 - 备案巴巴 | 高压油管,液压接头,液压附件-烟台市正诚液压附件 | 诺冠气动元件,诺冠电磁阀,海隆防爆阀,norgren气缸-山东锦隆自动化科技有限公司 | 液氮罐_液氮容器_自增压液氮罐_杜瓦瓶_班德液氮罐厂家 | 猎头招聘_深圳猎头公司_知名猎头公司| 高博医疗集团上海阿特蒙医院| 培训无忧网-教育培训咨询招生第三方平台 | LED投光灯-工矿灯-led路灯头-工业灯具 - 山东普瑞斯照明科技有限公司 | 探鸣起名网-品牌起名-英文商标起名-公司命名-企业取名包满意 | 合肥网带炉_安徽箱式炉_钟罩炉-合肥品炙装备科技有限公司 | 氧化铁红厂家-淄博宗昂化工 | 风化石头制砂机_方解石制砂机_瓷砖石子制砂机_华盛铭厂家 | 道康宁消泡剂-瓦克-大川进口消泡剂供应商 | 深圳展厅设计_企业展馆设计_展厅设计公司_数字展厅设计_深圳百艺堂 | 无负压供水设备,消防稳压供水设备-淄博创辉供水设备有限公司 | 青岛球场围网,青岛车间隔离网,青岛机器人围栏,青岛水源地围网,青岛围网,青岛隔离栅-青岛晟腾金属制品有限公司 | 防腐木批发价格_深圳_惠州_东莞防腐木厂家_森源(深圳)防腐木有限公司 | 3d打印服务,3d打印汽车,三维扫描,硅胶复模,手板,快速模具,深圳市精速三维打印科技有限公司 | 除甲醛公司-甲醛检测治理-杭州创绿家环保科技有限公司-室内空气净化十大品牌 | 高尔夫球杆_高尔夫果岭_高尔夫用品-深圳市新高品体育用品有限公司 | 复合土工膜厂家|hdpe防渗土工膜|复合防渗土工布|玻璃纤维|双向塑料土工格栅-安徽路建新材料有限公司 | 有机肥设备生产制造厂家,BB掺混肥搅拌机、复合肥设备生产线,有机肥料全部加工设备多少钱,对辊挤压造粒机,有机肥造粒设备 -- 郑州程翔重工机械有限公司 | 多功能干燥机,过滤洗涤干燥三合一设备-无锡市张华医药设备有限公司 |