Dynamic change the upload folder name

Oct 7, 2010 at 1:46 AM


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

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

    <fjx:FileUploader ID="FileUploader1" runat="server">
        <fjx:DirectAmazonUploader OnFileNameDetermining="FileUploader1_FileNameDetermining"
            BucketName="media.sitename.com" />


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.


Nov 5, 2010 at 1:45 AM

Hi coder29

I'm using the following code to set the Path property of the DirectAmazonUploader in one of my pages:

Private Sub page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        If Not IsPostBack Then
            Dim fjxUploader As com.flajaxian.FileUploader = CType(Me.Master.FindControl("ContentPlaceHolder1").FindControl("awsUploader"), com.flajaxian.FileUploader)
            Dim fjxAWSUploader As com.flajaxian.DirectAmazonUploader = CType(fjxUploader.Adapters(0), com.flajaxian.DirectAmazonUploader)
            fjxAWSUploader.Path = "MYPATH"
        End If
    End Sub

A couple of remarks:
1: It's not that pretty but it works :-)
2: Change the 'awsUploader' control ID to your own tag ID :-)
2: As you can see I use Master Pages in this web app. Use something like 'Dim fjxUploader As com.flajaxian.FileUploader = CType(Me.FindControl("awsUploader"), com.flajaxian.FileUploader)' if you don't
3: As you can see I put the code in the PreRender event of the page life cycle. Initially I put the code in the OnLoad event, but it seems like the DirectAmazonUploader control removes the Path value somewhere between OnLoad and PreRender in the page life cycle. Setting the property in PreRender solves that.
4: This example sets the Path property to a static value (so you could just as easily have set the property directly in the markup), of course you would create the path based on database data or something like that in your own production code

Hope this solves your problem.

Mar 24, 2011 at 3:42 PM


I'm having problems setting the path dynamically as well.

Actually, I'm able to set the path OnLoad. However, the problem is when I try to update the Path on later postbacks.

For example, if on page load (or pre render - I tried both and then some) I set the path to "MyFolder", files get uploaded successfully to that folder. However, if I later click a linkbutton that sets the path to say .. "MyFolder/SubFolder" and try to upload files after, the files still go to "MyFolder".