Get uploaded real file name!!!

Last post 04-04-2014, 8:17 AM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  04-04-2014, 4:53 AM 80215

    Get uploaded real file name!!!

    Hi guys, I have the following problem.

    WHen I try to upload files in different times, could happens that the name of a file is the same of a file aready present on the target destination. In that case, the uploader class provides to rename the new file, but I can't get the new filename...

    The code I'm using is the following: 

     

              <%

                    Dim uploader

                    Set uploader=new AspUploader

                    uploader.Name="myuploader"

                    

                    uploader.MaxSizeKB=10240

                    uploader.InsertText="Upload File (Max 10M)"

                   uploader.AllowedFileExtensions="*.pdf,*.jpg"

                    uploader.MultipleFilesUpload=true

                    

                    uploader.SaveDirectory="documents"

                    

                    uploader.render()

                %>

     

     

     

    <script type='text/javascript'>

          function CuteWebUI_AjaxUploader_OnTaskComplete(task)

          {

                savefiletodbrequest(task.FileName);

          }

     </script>

     

  •  04-04-2014, 8:17 AM 80219 in reply to 80215

    Re: Get uploaded real file name!!!

    Hi Gianluca,

     

    For now has not the option to get this new file name. I suggest you handle the upload file store file name by method "CopyTo()", so you can always get the correct file name. The example page below shows you how to use method CopyTo to handle the upload file store location and the file name. 

     

    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.CopyTo(Server.MapPath(".")&"/savefiles/"&mvcfile.FileName)  
    38.     Next  
    39. End If  
    40.   
    41. %>  
    42.               
    43.     </div>  
    44. </body>  
    45. </html>  
     

    Regards,

     

    Ken 

View as RSS news feed in XML