Grabbing the Filename and re-naming

Last post 11-21-2013, 9:53 AM by Badgerator. 2 replies.
Sort Posts: Previous Next
  •  11-20-2013, 9:40 AM 78398

    Grabbing the Filename and re-naming

    Hi there,

     

    I am using ASP Uploader to add a picture to a set of data posted by a standard HTML form. I am trying to grab the filename of the upload and insert it into a database on submit. I tried capturing it via Request.Form("myuploader") but this just captures the key, what is the form or session variable for the actual file name?

     

    Many Thanks

     

    Duncan 

     

     

     

  •  11-21-2013, 7:53 AM 78404 in reply to 78398

    Re: Grabbing the Filename and re-naming

    Hi Badgerator,

     

    Please try the example below. you can get the upload file name by "mvcfile.FileName" in line 37.

     

    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.         example  
    8.     </title>  
    9. </head>  
    10. <body>  
    11.     <div>                          
    12.             <form id="form1" method="POST">  
    13.             <%  
    14.             Dim uploader  
    15.             Set uploader=new AspUploader  
    16.             uploader.MaxSizeKB=10240  
    17.             uploader.Name="myuploader"  
    18.             uploader.InsertText="Upload File (Max 10M)"  
    19.             uploader.MultipleFilesUpload=true  
    20.             %>  
    21.             <%=uploader.GetString() %>  
    22.             </form>  
    23.               
    24.             <br/><br/>  
    25. <%  
    26. If Request.Form("myuploader")&""<>"" Then  
    27.   
    28.     Dim list,i  
    29.       
    30.     'Gets the GUID List of the files based on uploader name   
    31.     list=Split(Request.Form("myuploader"),"/")  
    32.   
    33.     For i=0 to Ubound(list)  
    34.         Dim mvcfile  
    35.         'get the uploaded file based on GUID  
    36.         Set mvcfile=uploader.GetUploadedFile(list(i))  
    37.         'mvcfile.FileName is the upload file name  
    38.         'save the upload file by method CopyTo  
    39.         mvcfile.CopyTo(Server.MapPath(".")&"/savefiles/"&mvcfile.FileName)  
    40.     Next  
    41. End If  
    42.   
    43. %>  
    44.               
    45.     </div>  
    46. </body>  
    47. </html>  
     

    Regards,

     

    Ken 

  •  11-21-2013, 9:53 AM 78406 in reply to 78404

    Re: Grabbing the Filename and re-naming

    Perfect, thanks Ken!
View as RSS news feed in XML