Resolved: OnFileNameDetermining

Nov 20, 2010 at 9:33 AM

Using the following code:

<script runat="server">
private void ConfirmUpload(object sender, ConfirmUploadEventArgs e)
{
    // if you don't want to do anything on the server 
    // just leave it empty
}

private void FileUploader1_FileNameDetermining(object sender, FileNameDeterminingEventArgs e)
{
    // set the filename here
    // you can also use e.File - HttpPostedFile object

    Random r = new Random();

    String OverwriteFileName = r.Next(10000).ToString()+DateTime.Now+e.FileName;
    OverwriteFileName.Replace(" ","_");
    OverwriteFileName.Replace("-", "");
    OverwriteFileName.Replace(":", "");

    e.FileName = OverwriteFileName;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <fjx:FileUploader ID="FileUploader1" runat="server" 
    OnConfirmUpload="ConfirmUpload" 
    OnFileNameDetermining="FileUploader1_FileNameDetermining">
    <%--Path="ParentFolder/Folder1"--%>
    <Adapters>
        <fjx:DirectAmazonUploader 
            FileAccess="Private"
            AccessKey="WebConfig:AmazonAccessKey"
            SecretKey="WebConfig:AmazonSecretKey"
            BucketName="test"  />
    </Adapters>
</fjx:FileUploader>
    </div>
    </form>
</body>
</html>
The file uploads, but is it not renamed. Any ideas?

Nov 20, 2010 at 10:35 AM

Fixed: I had the parameters in the FileUploader tag instead of the DirectAmazonUploader tag