| 定義創(chuàng)建文件上載控件,該控件帶有一個文本框和一個瀏覽按鈕。 Creates a file upload object with a text box and Browse button. 注釋要使得文件上載能夠成功,要做到以下幾點: 
 要處理上載到服務(wù)器的文件,服務(wù)器端進(jìn)程必須可以處理 multipart/form-data 的提交。例如,Microsoft Posting Acceptor 能夠允許 Microsoft Internet Information Server (IIS) 接受文件上載。而在網(wǎng)上也可找到其它的 Common Gateway Interface (CGI) 腳本用于處理 multipart/form-data 提交。 此元素在 Internet Explorer 4.0 及以上版本的 HTML 和腳本中可用。而文件上載 add-on 要求在 Internet Explorer 3.02 中使用 INPUT type=file 元素。用戶可以在文本框中輸入文件路徑或者單擊瀏覽按鈕在文件系統(tǒng)中瀏覽。 此元素是一個內(nèi)嵌元素。 此元素不需要關(guān)閉標(biāo)簽。 For a file upload to take place: 
 To handle a file upload to the server, a server-side process must be running that can handle multipart/form-data submissions. For example, the Microsoft Posting Acceptor allows Microsoft Internet Information Server (IIS) to accept file uploads. Additional Common Gateway Interface (CGI) scripts that can handle multipart/form-data submissions are available on the Web. The INPUT type=file element is available in HTML and script as of Internet Explorer 4.0. The file upload add-on is required to use the INPUT type=file element in Internet Explorer 3.02. Users can enter a file path in the text box or click the Browse button to browse the file system. When a file is uploaded, the file name is also submitted. The path of the file is available only to the machine within the Local Machine security zone. The value property returns only the file name to machines outside the Local Machine security zone. See About URL Security Zones for more information on security zones. This element is an inline element. This element does not require a closing tag. 示例代碼下面的例子使用 INPUT type=file 元素將文件上載到服務(wù)器上。第一個例子要求 Microsoft Posting Acceptor, Microsoft Posting Acceptor 可與 IIS 或 Personal Web Server 一起使用。 該示例使用 HTML 代碼提交用戶選中的文件到 Cpshost.dll,該服務(wù)器組件由 Posting Acceptor 安裝。 The following examples use the INPUT type=file element to upload a file to a server. The first example requires Microsoft Posting Acceptor, which can be used with IIS or Personal Web Server. This example uses HTML code to submit a file selected by the user to Cpshost.dll, which is installed with Posting Acceptor. <FORM NAME="oForm" ACTION="repost.asp" ENCTYPE="multipart/form-data" METHOD="post"> <INPUT TYPE="file" NAME="oFile1"/> <INPUT TYPE="submit" VALUE="Upload File"> </FORM> 下面的例子顯示了 Repost.asp 的 ASP 內(nèi)容。請注意,上載文件的屬性可從提交表單中訪問。 This example shows the Active Server Page (ASP) content of Repost.asp. Notice that the properties of the uploaded file are accessible from the submitted form. <%@ LANGUAGE = JScript %> <% Response.buffer=true; %> <HTML> <TITLE>Repost Example</TITLE> <BODY> <H1>Upload Status</H1> <P> Destination: <B><% Response.Write(Server.HTMLEncode(Request.Form("TargetURL"))) %></B> </P> <%    Response.write("<P>Name: " + Server.HTMLEncode(Request.Form("FileName")) + "</P>");    Response.write("<P>Size: " + Server.HTMLEncode(Request.Form("FileSize")) + "</P>");    Response.write("<P>Path: " + Server.HTMLEncode(Request.Form("FilePath")) + "</P>"); %> </BODY> </HTML> 另見 | 
|  |