Re: Uploading / renaming files using Ajax - Newbie question

  •  11-03-2010, 1:13 AM

    Re: Uploading / renaming files using Ajax - Newbie question

    Hi Edd,
     
    Please try the example below, it shows you how to add the timestamp into the file name.
     
    Note: need to change the path "C:\inetpub\wwwroot\aspuploader\uploads\ " to yours.
     
     
    1. <%@ Language="VBScript" %>  
    2. <!-- #include file="aspuploader/include_aspuploader.asp" -->  
    3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
    4. <html xmlns="http://www.w3.org/1999/xhtml">  
    5. <head>  
    6.     <title>  
    7.         Form - Multiple files upload  
    8.     </title>  
    9.     <link href="demo.css" rel="stylesheet" type="text/css" />  
    10.       
    11.     <script type="text/javascript">  
    12.     function CuteWebUI_AjaxUploader_OnPostback() {  
    13.         //submit the form after the file have been uploaded:  
    14.         document.forms[0].submit();  
    15.     }  
    16.     </script>  
    17. </head>  
    18. <body>  
    19.     <div class="demo">                          
    20.         <h2>Selecting multiple files for upload</h2>  
    21.         <p>ASP Uploader allows you to select multiple files and upload multiple files at once.</p>  
    22.           
    23.             <!-- do not need enctype="multipart/form-data" -->  
    24.             <form id="form1" method="POST">  
    25.             <%  
    26.             Dim uploader  
    27.             Set uploader=new AspUploader  
    28.             uploader.MaxSizeKB=10240  
    29.             uploader.Name="myuploader"  
    30.             uploader.InsertText="Upload File (Max 10M)"  
    31.             uploader.MultipleFilesUpload=true  
    32.             %>  
    33.             <%=uploader.GetString() %>  
    34.             </form>  
    35.               
    36.             <br/><br/>  
    37. <%  
    38.   
    39. If Request.Form("myuploader")&""<>"" Then  
    40.   
    41.     Dim list,i  
    42.       
    43.     'Gets the GUID List of the files based on uploader name   
    44.     list=Split(Request.Form("myuploader"),"/")  
    45.   
    46.     For i=0 to Ubound(list)  
    47.         if i>0 then  
    48.             Response.Write("<hr/>")  
    49.         end if  
    50.         Dim mvcfile  
    51.           
    52.         'get the uploaded file based on GUID  
    53.         Set mvcfile=uploader.GetUploadedFile(list(i))  
    54.   
    55.         Response.Write("<div style='font-family:Fixedsys'>")  
    56.         Response.Write("Uploaded File:")  
    57.          'Gets the name of the file.  
    58.         Response.Write("<br/>FileName: ")  
    59.         Response.Write(mvcfile.FileName)  
    60.         'Gets the size of the file.  
    61.         Response.Write("<br/>FileSize: ")  
    62.         Response.Write(mvcfile.FileSize)  
    63.         'Gets the temp file path.   
    64.         Response.Write("<br/>FilePath: ")  
    65.         Response.Write(mvcfile.FilePath)  
    66.         Response.Write("</div>")  
    67.         'Copys the uploaded file to a new location.      
    68.       
    69.         mvcfile.MoveTo("C:\inetpub\wwwroot\aspuploader\uploads\" & Year(Date) & "-" & Month(Date()) & "-" & Day(Date()) & "-" & Hour(Time()) & "-" & Minute(Time())& "-" &  mvcfile.FileName)   
    70.           
    71.                   
    72.                    
    73.   
    74.         'Moves the uploaded file to a new location.      
    75.         
    76.   
    77.     Next  
    78. End If  
    79.   
    80. %>  
    81.               
    82.     </div>  
    83. </body>  
    84. </html>  
    Also what rights do we need to give to the uploaded temporary and final directories?  
     
    You need to have write/read permission of them.
     
    Regards,
     
    ken 
View Complete Thread