热情软件屋

 

怎样用ASP实现文件上传


编号:QA001926
建立日期: 1999年10月28日 最后修改日期:1999年10月28日
所属类别:

richb:
    asp
    WindowsNT
    怎样用ASP实现文件的传输,主要指文件的上传?

回答:

    下面内容摘自
    微软的Knowledge Base的文章:“Q217425 Simple ASP Example Using Posting Acceptor”
    


    SUMMARY
    =======
    Microsoft Posting Acceptor is a server add-on component in the Windows NT Option Pack (NTOP) that enables the use of HTTP Post (RFC 1867) to publish content to your Web site.
    
    MORE INFORMATION
    ================
    To get Posting Acceptor to work with as few steps as possible, perform the following steps:
    
    1. Install Posting Acceptor using one of the following methods:
     - Install Posting Acceptor during the NTOP installation.
     -OR-
     - Run the NTOP setup and specify Add/Remove.
    2. In either of the above methods, specify the installation of Posting Acceptor, by doing the following:
     a. Select Microsoft Site Server Express 2.0.
     b. Click Show Subcomponents.
     c. Select Publishing - Posting Acceptor.
     d. Click OK and complete the wizard.
    3. Verify that the Cpshost.dll file is in your Scripts folder.
    4. Create a new directory named Uploads and give it at least NTFS Add permissions to valid users, but ensure that the "Everyone" and IUSR_COMPUTERNAME accounts do not have rights to the folder.
    5. Create a new virtual directory that points to the new Uploads directory with write access.
    6. Create a new text file named Postacpt.asp in your Scripts folder and paste the following HTML code into it:
    
   <SCRIPT RUNAT=SERVER LANGUAGE="JavaScript">
    if (Request.ServerVariables("LOGON_USER") == '')
      Response.Status('401 Access Denied');
   </SCRIPT>
   <html>
   <body>
   <form enctype="multipart/form-data" 
     action="/scripts/cpshost.dll?PUBLISH" method="POST">
    <center><table>
      <tr>
        <td align="left">File to upload</td>
        <td align="left"><input name="file" type="file" size="20"></td>
      </tr>
      <tr>
        <td align="left">Destination URL</td>
        <td align="left">
        <input name="TargetURL" value="/uploads/" size="20">
        <input type="Submit" value="Upload..."></td>
      </tr>
    <table></center>
   </form>
   </body>
   </html>
Notes on the above code sample: - The JavaScript code forces a browser to authenticate. You can remove this code to allow anonymous posting, otherwise you will need to add users/groups as specified in the step above. - The form uses a new input of type "file" that should display a Browse button on the Web page. 7. Browse the page at "http://localhost/scripts/postacpt.asp" and upload a file to verify the correct functionality. For additional information, please see the following article(s) in the Microsoft Knowledge Base: Q184352 HOWTO: Upload files to the Internet Information Server Q189651 SAMPLE: Uploading a File to IIS Using a Browser

此问题由李海回答。

 
把这个问题推荐给朋友
   
   
您的意见类别
您的名字
您的电子邮件
您的建议(请尽可能详细)
 
 

版权所有 1997-2008 热情软件屋
如果您有任何建议和意见, 请给我发个电子邮件 askpro@china-askpro.com
Web Designed by ZebraStudio