Live Support, Chat, Upload Control and Rich Text Editor
Welcome to Support forums Sign in | Join | Help |Client Center
in Search

Upload to virtual directory?

Last post 06-28-2011, 10:41 AM by Eric. 1 replies.
Sort Posts: Previous Next
  •  06-27-2011, 2:05 PM 68177

    Upload to virtual directory?

    When I use a format like this for uploader.SaveDirectory...
     
    uploader.SaveDirectory="../upload"
     
    ...it seems to be looking for a physical path. I would like to upload to a virtual path that's outside the actual web folder in IIS, but I can't seem to do that.
     
    Is there a way?
  •  06-28-2011, 10:41 AM 68204 in reply to 68177

    Re: Upload to virtual directory?

    Hi GenNS,
     
    Yes, this can be implemented.
    You can follow steps:
    1. Open IIS
    2. Navigate to the site which contains the ASP Uploader
    3. Create one virtual directory "savefoldervirdir" and let it point to the destination folder
    4. Save the following code to test.asp:
    <%@ Language="VBScript" %>
    <!-- #include file="aspuploader/include_aspuploader.asp" -->
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
     <title>
      Form - Multiple files upload
     </title>
     <link href="demo.css" rel="stylesheet" type="text/css" />
     
     <script type="text/javascript">
     function CuteWebUI_AjaxUploader_OnPostback() {
      //submit the form after the file have been uploaded:
      document.forms[0].submit();
     }
     </script>
    </head>
    <body>
     <div class="demo">                       
            <h2>Selecting multiple files for upload</h2>
      <p>ASP Uploader allows you to select multiple files and upload multiple files at once.</p>
      
       <!-- do not need enctype="multipart/form-data" -->
       <form id="form1" method="POST">
       <%
       Dim uploader
       Set uploader=new AspUploader
       uploader.MaxSizeKB=1024000
       uploader.Name="myuploader"
       uploader.InsertText="Upload File (Max 10M)"
       uploader.MultipleFilesUpload=true
       %>
       <%=uploader.GetString() %>
       </form>
       
       <br/><br/>
    <%

    If Request.Form("myuploader")&""<>"" Then

     Dim list,i
     
     'Gets the GUID List of the files based on uploader name
     list=Split(Request.Form("myuploader"),"/")

     For i=0 to Ubound(list)
      if i>0 then
       Response.Write("<hr/>")
      end if
      Dim mvcfile
      
      'get the uploaded file based on GUID
      Set mvcfile=uploader.GetUploadedFile(list(i))

      Response.Write("<div style='font-family:Fixedsys'>")
      Response.Write("Uploaded File:")
       'Gets the name of the file.
      Response.Write("<br/>FileName: ")
      Response.Write(mvcfile.FileName)
      'Gets the size of the file.
      Response.Write("<br/>FileSize: ")
      Response.Write(mvcfile.FileSize)
      'Gets the temp file path.
      Response.Write("<br/>FilePath: ")
      Response.Write(mvcfile.FilePath)
      Response.Write("</div>")
      'Copys the uploaded file to a new location.  
       'savefoldervirdir is the name of virtual directory which points to the outside path of your actual web folder
       mvcfile.CopyTo(Server.MapPath("savefoldervirdir"))            
       'Moves the uploaded file to a new location.    
      'mvcfile.MoveTo(Server.MapPath("savefoldervirdir"))  
     Next
    End If
    %>
       
     </div>
    </body>
    </html>
     
    5. Run test.asp and check whether files are uploaded to the destination folder.
     
    Thanks for asking
     
View as RSS news feed in XML
Powered by ASP.Net
Copyright 2003 - 2017 CuteSoft Components Inc.. All rights reserved.