File renaming

Last post 03-02-2012, 8:30 AM by arildog. 5 replies.
Sort Posts: Previous Next
  •  03-01-2012, 3:05 AM 73266

    File renaming

    Hi,
    I need to differentiate between files that are uploaded from several clients by client code (uploaded to the same folder). Is there a simple property allowing for adding this code to each file that is uploaded (e.g., ClientCode_Myuploadedfile1.gif, ClientCode_Myuploadedfile2.gif)? Alternatively, can you please propose a VBscript for this?
  •  03-01-2012, 6:29 AM 73272 in reply to 73266

    Re: File renaming

    Hi arildog,
     
    The example below shows you how to handle the upload file store location and the file name by method "CopyTo".
     
    <%@ 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 - Single File Upload
    </title>
    </head>
    <body>
    <div class="demo">
                            
            <h2>Single File Upload</h2>
    <p> A basic sample demonstrating the use of the Upload control.</p>
    <!-- do not need enctype="multipart/form-data" -->
    <form id="form1" method="POST">
    <%
    Dim uploader
    Set uploader=new AspUploader
    uploader.MaxSizeKB=10240
    uploader.Name="myuploader"
    uploader.InsertText="Upload File (Max 10M)"
    uploader.MultipleFilesUpload=true
    %>
    <%=uploader.GetString() %>
    </form>
    <br/><br/>
    <%
    If Request.Form("myuploader")&""<>"" Then
    Dim mvcfile
    Set mvcfile=uploader.GetUploadedFile(Request.Form("myuploader"))
        mvcfile.CopyTo ("C:\inetpub\wwwroot\aspuploader\test\myPhoto.jpg")
    End If
    %>
    </div>
    </body>
    </html>
     
    Regards,
     
    Ken 
  •  03-01-2012, 9:03 AM 73274 in reply to 73272

    Re: File renaming

    Perfect, Ken! Thank you for excellent and swift support.
  •  03-01-2012, 2:24 PM 73277 in reply to 73274

    Re: File renaming

    Oops - I'm stuck again: what if the uploaded file is not a ".jpg"? Can you please indicate how I keep the original suffix intact.
  •  03-02-2012, 8:00 AM 73289 in reply to 73277

    Re: File renaming

    Hi arildog,
     
     mvcfile.CopyTo ("C:\inetpub\wwwroot\aspuploader\test\"+mvcfile.FileName)  
     
      mvcfile.FileName is the original file name.
     
    Regards,
     
    Ken 
  •  03-02-2012, 8:30 AM 73291 in reply to 73289

    Re: File renaming

    Thanks again. Works perfectly.
View as RSS news feed in XML