开发者

Dynamically change the Flajaxian upload folder name

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开发者_StackOverflow(10000) + ".jpg";

    }

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

Thanks.


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


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;


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜