File Name Suffix

Last post 12-13-2011, 9:51 AM by Raiden. 6 replies.
Sort Posts: Previous Next
  •  11-30-2011, 3:11 PM 71741

    File Name Suffix

    Hi!
     
    I'm looking for a way to add a suffix to the filenames. I searched trough the deployment doc but cannot find the answer.
     
    The files that the user upload are part of a ticketing system. I would like to be able to add the ticket ID as the suffix of the file
     
    Exemple:
     
    "filename.txt" would become "1234 - filename.txt"
     
    Any ideas?
     
    Thanks!
     
    Edit: Adding a Suffix or just completly renaming the file would be great: ex: "1234.txt"
     
     
     
  •  12-01-2011, 10:39 AM 71759 in reply to 71741

    Re: File Name Suffix

    Hi Raiden,
     
    You can handle the upload file save location and the file name by method "MoveTo". Try the example below
     

    <%@ 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.FileName is the original file name
             mvcfile.MoveTo("C:\inetpub\wwwroot\aspuploader\photos\1234-"+mvcfile.FileName)
    End If
    %>
    </div>
    </body>
    </html>
     
    Regards,
     
    Ken 
  •  12-06-2011, 10:46 AM 71819 in reply to 71759

    Re: File Name Suffix

    Thanks!
     
    However, I don't submit any forms when I use the script.
     
    Would'nt it be possible to just create a uploader.filename = "filename" option?

    Thanks! 
  •  12-07-2011, 6:31 AM 71847 in reply to 71819

    Re: File Name Suffix

    Hi Raiden,
     
    You can start the upload when the form submit, like example http://aspuploader.com/demo/form-manualstart.asp
     
    The form submit is necessary if you want to upload the file to the server.
     
    Regards,
     
    Ken 
  •  12-12-2011, 10:23 AM 71966 in reply to 71847

    Re: File Name Suffix

     
    It works perfectly, and I don't have to submit any forms.
     
    Submitting the form would actually cause an issue for me so I want to avoid that
     
    Thanks! 
  •  12-13-2011, 8:24 AM 71992 in reply to 71966

    Re: File Name Suffix

    Hi Raiden,
     
    If you just need to get the value at client site, please try API "function CuteWebUI_AjaxUploader_OnSelect(files)"
     

    function CuteWebUI_AjaxUploader_OnSelect(files)

    {

        var name=files[0].FileName;

        var size=files[0].FileSize // (or -1)

    }

    Regards,
     
    Ken 
  •  12-13-2011, 9:51 AM 71994 in reply to 71992

    Re: File Name Suffix

    I already have the name and path.
     
    I just need to specify the name of the file I want to save. Renaming the file.
     
    So when the script upload the file, instead of putting "realname.txt" it would save it as "newname.txt"
View as RSS news feed in XML