files are uploading twice in single click event

Apr 16, 2010 at 12:10 PM

Hi,

 

I am trying to configure the Flajaxian Upload Control. the below is the code.

 

<fjx:FileUploader ID="FileUploader1" runat="server" IsDebug="true" AllowedFileTypes="Web Images (Jpeg, Gig, Png):*.jpg;*.jpeg;*.png;*.gif" >
    <Adapters>
        <fjx:FileSaverAdapter runat="server" FolderName="uploads" OnFileNameDetermining="FileNameDetermining" />
    </Adapters>
</fjx:FileUploader>

 

 

private Random random = new Random();
    protected void Page_Load(object sender, EventArgs e)
    {
        Session["test"] = "hi";
    }
    
    protected void FileNameDetermining(object sender, FileNameDeterminingEventArgs args)
    {
        string strBaseLocation = Server.MapPath("~") + "\\uploads\\";
        int _lastIndexExtensionValue = args.FileName.LastIndexOf(".");
        string _extension = args.FileName.Substring(_lastIndexExtensionValue);
        args.File.SaveAs(strBaseLocation + Session.SessionID + "-" + GenerateRandomCode() + _extension);
    }
    private string GenerateRandomCode()
    {
        string s = "";
        for (int i = 0; i < 6; i++)
            s = String.Concat(s, this.random.Next(10).ToString());
        return s;
    }

 

 

the files are uploading twice , one file is with original name and other file name is session id name.

can any one resolve my problem.

 

regards

Srikanth Dasari

Coordinator
Apr 16, 2010 at 3:38 PM

protected void FileNameDetermining(object sender, FileNameDeterminingEventArgs args)
    {
        string strBaseLocation = Server.MapPath("~") + "\\uploads\\";
        int _lastIndexExtensionValue = args.FileName.LastIndexOf(".");
        string _extension = args.FileName.Substring(_lastIndexExtensionValue);
        args.File.SaveAs(strBaseLocation + Session.SessionID + "-" + GenerateRandomCode() + _extension);

        args.CancelProcessing = true;


    }

Apr 16, 2010 at 5:08 PM

Thanks ALOT :)

Its working