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

    1. <tfoot id='zDqKK'></tfoot>
        <bdo id='zDqKK'></bdo><ul id='zDqKK'></ul>

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

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

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

      1. 如何使用包含文件和發(fā)布數(shù)據(jù)的 JavaScript 創(chuàng)建

        How to create an AJAX request with JavaScript that contains both file and post data(如何使用包含文件和發(fā)布數(shù)據(jù)的 JavaScript 創(chuàng)建 AJAX 請求)

            <tbody id='YnwVm'></tbody>
        1. <legend id='YnwVm'><style id='YnwVm'><dir id='YnwVm'><q id='YnwVm'></q></dir></style></legend>
          <tfoot id='YnwVm'></tfoot>
        2. <small id='YnwVm'></small><noframes id='YnwVm'>

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

                1. 本文介紹了如何使用包含文件和發(fā)布數(shù)據(jù)的 JavaScript 創(chuàng)建 AJAX 請求的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  如何創(chuàng)建一個 HTTP 請求,該請求使用 PHP 服務(wù)器可以接收的 JavaScript 發(fā)送一個文件和一些 post 數(shù)據(jù)?

                  How can I create a HTTP request that sends one file and some post data with JavaScript that can be received by a PHP server?

                  我找到了以下建議,但似乎并不完整

                  I have found the following suggestion but it does not seem to be complete

                  xhr.open("POST", "upload.php");
                  var boundary = '---------------------------';
                  boundary += Math.floor(Math.random()*32768);
                  boundary += Math.floor(Math.random()*32768);
                  boundary += Math.floor(Math.random()*32768);
                  xhr.setRequestHeader("Content-Type", 'multipart/form-data; boundary=' + boundary);
                  var body = '';
                  body += 'Content-Type: multipart/form-data; boundary=' + boundary;
                  //body += '
                  Content-length: '+body.length;
                  body += '
                  
                  --' + boundary + '
                  ' + 'Content-Disposition: form-data; name="';
                  body += 'myfile"; filename="'+file.fileName+'" 
                  ';
                  body += "Content-Type: "+file.type;
                  body += '
                  
                  ';
                  body += file.getAsBinary();
                  body += '
                  '
                  body += '--' + boundary + '
                  ' + 'Content-Disposition: form-data; name="submitBtn"
                  
                  Upload
                  ';
                  body += '--' + boundary + '--';
                  xhr.setRequestHeader('Content-length', body.length);
                  

                  為了讓這個工作,我需要一個包含輸入類型文件字段的文件"變量,但是在哪里放置額外的帖子數(shù)據(jù)?我也想發(fā)送描述文本.假設(shè)我還需要使用 xhr.send 來發(fā)送請求...

                  To get this working I need to have a 'file' variable that contains an input type file field but where to put additional post data? I want to send a description text as well. suppose I would also need to use xhr.send to send the request...

                  推薦答案

                  額外的 POST 數(shù)據(jù)應(yīng)該作為另一個 Content-Disposition 放置.示例:

                  Additional POST data should be placed as another Content-Disposition. Example:

                  Content-Type: multipart/form-data; boundary=AaB03x
                  
                  --AaB03x
                  Content-Disposition: form-data; name="submit-name"
                  
                  Larry
                  --AaB03x
                  Content-Disposition: form-data; name="files"; filename="file1.txt"
                  Content-Type: text/plain
                  
                  ... contents of file1.txt ...
                  --AaB03x--
                  

                  這里發(fā)送了兩個變量:要上傳的文件和一個名稱 = "submit-name" 且值為 Larry 的輸入.您可以擁有與想要發(fā)布的變量一樣多的 Content-Disposition.

                  Here two variables are sent: the file to be uploaded and a input with name = "submit-name" and value Larry. You could have as many Content-Dispositions as variables you would like to POST.

                  當然,如果您使用像 jQuery 這樣的 js 框架,則可以簡化大部分管道.這是一個 優(yōu)秀插件 應(yīng)該 完成工作.

                  Of course much of the plumbing could be simplified if you used a js framework like jQuery. Here's an excellent plugin which should do the job.

                  這篇關(guān)于如何使用包含文件和發(fā)布數(shù)據(jù)的 JavaScript 創(chuàng)建 AJAX 請求的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會等待 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 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發(fā)技術(shù)分
                  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 部分內(nèi)容)
                  <tfoot id='RPDgK'></tfoot>
                2. <i id='RPDgK'><tr id='RPDgK'><dt id='RPDgK'><q id='RPDgK'><span id='RPDgK'><b id='RPDgK'><form id='RPDgK'><ins id='RPDgK'></ins><ul id='RPDgK'></ul><sub id='RPDgK'></sub></form><legend id='RPDgK'></legend><bdo id='RPDgK'><pre id='RPDgK'><center id='RPDgK'></center></pre></bdo></b><th id='RPDgK'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='RPDgK'><tfoot id='RPDgK'></tfoot><dl id='RPDgK'><fieldset id='RPDgK'></fieldset></dl></div>

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

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

                      • <bdo id='RPDgK'></bdo><ul id='RPDgK'></ul>
                          <tbody id='RPDgK'></tbody>

                            主站蜘蛛池模板: 成人在线视频免费观看 | 欧美日韩亚洲视频 | 欧美一级免费看 | 日韩在线h| 国产精品久久久久久网站 | 国产精品99999999 | 99热都是精品 | 91啪影院 | 成人在线观看免费 | 国产精品久久久久aaaa | 国产美女视频一区 | 国产精品成人一区二区 | 91福利网| 91影院| 日韩免费视频一区二区 | 免费看大片bbbb欧美 | 国产精品99久久久久久宅男 | 日本福利片 | 亚洲天堂一区 | 日韩视频免费看 | 免费一区二区三区 | 久久国产精品久久久久久 | 一区影视| 国产精品一区二区久久久久 | 成人做爰999 | 国产精品亚洲欧美日韩一区在线 | 草久久 | 老牛嫩草一区二区三区av | 在线成人av | 成人在线一区二区三区 | 成人欧美一区二区三区黑人孕妇 | 国产综合精品一区二区三区 | 一区二区三区四区免费在线观看 | 男女污污网站 | 日韩手机在线看片 | 久在线 | 免费一区在线 | 国产在线1| 久久久久久九九九九九九 | 午夜精品一区二区三区在线视 | 日本午夜一区 |