Dynamically change the Flajaxian upload folder name

1.1k views Asked by At

I am trying to dynamically change the upload folder name, but it's not working form me. Please help.

I am using the Flajaxian S3 Amazon uploader. The code as follows

<fjx:FileUploader ID="FileUploader1" runat="server">
<Adapters>
    <fjx:DirectAmazonUploader OnFileNameDetermining="FileUploader1_FileNameDetermining"
        AccessKey="WebConfig:AmazonAccessKey"
        SecretKey="WebConfig:AmazonSecretKey"
        BucketName="media.sitename.com" />
</Adapters>
</fjx:FileUploader>

Server side code as follows

    protected void Page_Load(object sender, EventArgs e)
    {

          ((com.flajaxian.DirectAmazonUploader)FileUploader1.Adapters[0]).Path = Request.Params["sid"].ToString();

    }

    protected void FileUploader1_FileNameDetermining(object sender, com.flajaxian.FileNameDeterminingEventArgs e)
    {
        Random r = new Random();
        e.FileName = r.Next(10000) + ".jpg";

    }

If I hard code the path, it's working fine. But dynamic update of path folder not working. Please help me.

Thanks.

3

There are 3 answers

1
crazyDiamond On

In your eventhandle FileUploader1_FileNameDetermining, from e in the even, you get FileName and File.FileName. Change FileName to whatever path your new folder is and append e.File.FileName to it. Works like a charm.

e.FileName = "C:\\NewPath\\" + e.File.FileName;
0
Thomas On

You need to remember to add a / at the end of your path.

0
Corbin On
((DirectAmazonUploader)FileUploader1.Adapters[0]).Path = PUTYOURVARIABLEHERE+"/";