Rename File

Last post 05-05-2011, 12:00 PM by Eric. 1 replies.
Sort Posts: Previous Next
  •  05-04-2011, 6:38 PM 67449

    Rename File

    I need to be able to rename the file that is being uploaded.  For example, if someone uploads file.pdf I want it to upload to the server as 1.pdf.  Is there a way to easily do this???
  •  05-05-2011, 12:00 PM 67454 in reply to 67449

    Re: Rename File

    Dear msandwisch,
     
    You can rename uploaded files in this method, please refer to the following code:
     
    <%@ Language="VBScript" %>   
    <!-- #include file="aspuploader/include_aspuploader.asp" -->  
    <html>   
    <head>   
    </head>   
    <body>   
            <form id="form1" method="POST">   
            <%   
                Dim uploader   
                Set uploader=new AspUploader   
                uploader.Name="myuploader"  
                uploader.Render()   
            %>   
            </form>   
                   
    <%   
      
    If Request.Form("myuploader")&""<>"" Then  
        Dim mvcfile   
        Set mvcfile=uploader.GetUploadedFile(Request.Form("myuploader"))   
        targetfilepath= "savefiles/myprefix_" & mvcfile.FileName  
        mvcfile.CopyTo( server.mappath(targetfilepath))
        mvcfile.MoveTo( server.mappath(targetfilepath))
        Response.Write("<div style='font-family:Fixedsys'>")   
        Response.Write("Uploaded File")   
        Response.Write("<br/><br/>FileName: ")   
        Response.Write(mvcfile.FileName)   
        Response.Write("<br/>FileSize: ")   
        Response.Write(mvcfile.FileSize)
        Response.Write("</div>")   
    End If %>
    </body>   
    </html>
     
    Thank you for asking
View as RSS news feed in XML