当前位置:萝卜系统下载站 > 技术开发教程 > 详细页面

《无组件上传文件》

《无组件上传文件》

更新时间:2019-04-27 文章作者:未知 信息来源:网络 阅读次数:

我只是照搬过来的,我也是刚找到。我自己还没看明白源码呢。:)<br>
你只有自己修改了。我把整个网页一起贴过来吧。谁英文好翻译一下。<br>
一页贴不下,分两页。<br>
Upload Form<br>
Usually, you use an HTML FORM to submit data from the browser to the web server. That form can contain text fields, checkbox, button and also a file type control to upload files. The user fills in the form with his data and submits the form to the server.<br>
<br>
The enctype attribute of the &lt;FORM&gt; element specifies the content type used to encode the form data set for submission to the server. The enctype attribute used by default is &quot; application/x-www-form-urlencoded &quot;. However, that enctype is inefficient for sending large quantities of text, text containing non-ASCII characters or binary data to the server. The content type &quot; multipart/form-data &quot; should be used to submit forms in case of file uploading. Actually, it can be used to submit files and binary data. <br>
<br>
A &quot; multipart/form-data &quot; message contains a series of parts, where each part is expected to contain: <br>
<br>
a Content-Disposition header whose value is &quot; form-data &quot; <br>
a name attribute specifying the control name. <br>
For a file type control, the part contains some more information:<br>
<br>
a filename attribute specifying the original path and file name on the client <br>
a Content-Type header of the binary data control sent. <br>
Those headers are followed by the binary or text content of the control.<br>
<br>
The following example illustrates &quot; multipart/form-data &quot; encoding. The client would have this form in the browser: <br>
<br>
&lt;FORM METHOD=&quot;POST&quot; ENCTYPE=&quot;multipart/form-data&quot; ACTION=&quot;upload.asp&quot;&gt;<br>
&lt;INPUT TYPE=&quot;Text&quot; NAME=&quot;email&quot; VALUE=&quot;PhCollignon@email.com&quot;&gt;&lt;BR&gt;<br>
&lt;INPUT TYPE=&quot;file&quot; NAME=&quot;blob&quot;&gt;&lt;BR&gt;<br>
&lt;INPUT TYPE=&quot;submit&quot; NAME=&quot;Enter&quot;&gt;<br>
&lt;/FORM&gt;<br>
<br>
<br>
<br>
If this form is submitted, the following request can be read on the server:<br>
<br>
-----------------------------7cf87224d2020a <br>
Content-Disposition: form-data; name=&quot;email&quot; <br>
<br>
PhCollignon@email.com<br>
-----------------------------7cf87224d2020a<br>
Content-Disposition: form-data; name=&quot;blob&quot;; filename=&quot;c:\image.gif&quot;<br>
Content-Type: image/pjpeg <br>
<br>
&yuml;&Oslash;&yuml;àJFIFHH&yuml;&Ucirc;C…<br>
…&yuml;&Ugrave; <br>
-----------------------------7cf87224d2020a <br>
Content-Disposition: form-data; name=&quot;Enter&quot; <br>
<br>
Submit Query <br>
-----------------------------7cf87224d2020a-- <br>
<br>
That content can be displayed if it is sent back as a response to the client. The binary data should be read and written with Request.binaryRead and Response.binaryWrite methods.<br>
<br>
&lt;%<br>
Response.BinaryWrite(Request.BinaryRead(Request.TotalBytes))<br>
%&gt;<br>
<br>
You can see that parts of the response are delimited by boundaries:<br>
<br>
-----------------------------7cf87224d2020a<br>
<br>
and the last boundary is followed by: ' -- ' <br>
<br>
<br>
There is one Content-Disposition for each control. The name attribute identifies the control sent by the HTML form (email, blob and Enter). For a file type control (blob), the file name is also part of Content-Disposition header and, a Content-Type header gives the content type of the binary data. <br>
<br>

温馨提示:喜欢本站的话,请收藏一下本站!

本类教程下载

系统下载排行

网站地图xml | 网站地图html