This is a migrated thread and some comments may be shown as answers.

Example Please?

3 Answers 79 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Aaron
Top achievements
Rank 1
Aaron asked on 25 Sep 2012, 01:35 AM
Can you please give me an ASP.NET 4.0 VB.NET example of uploading to /images/post/ directory and renaming the image to a session value - with a 1, 2, 3, 4 etc saved after each file name?  The 1, 2, 3, 4 is just used to signify different images or else the images would just overwrite each other.

I will only be upload .jpg images!

Thanks!

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 Sep 2012, 05:12 AM
Hi Aaron,

Try the following code to achieve your scenario.

protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
    {
        string targetFolder = RadAsyncUpload1.TargetFolder;
        int cnt = Convert.ToInt16(Session["value"].ToString());
        string newName = "newName"+cnt.ToString();
        e.File.SaveAs(Path.Combine(Server.MapPath(targetFolder), newName + e.File.GetExtension()));
        Session["value"] = ++cnt;
    }

Thanks,
Princy.
0
Aaron
Top achievements
Rank 1
answered on 25 Sep 2012, 07:02 AM
Isnt that resetting my session value at the end?

Session["value"] = ++cnt;
0
Princy
Top achievements
Rank 2
answered on 26 Sep 2012, 05:25 AM
Hi Aaron,

In the beginning of a session you can get the value from the Database and store it in the session. In each file upload you can get the value from the session for saving the file and increment the session value.

Hope this helps.

Thanks,
Princy.
Tags
AsyncUpload
Asked by
Aaron
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Aaron
Top achievements
Rank 1
Share this question
or