Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using Ajax File Uploader control for uploading multiple file, which work well,

but my problem is i want to put all images uploaded by FileUploader, in one column of database table, separated by comma,

so for this, firstly i want to use array and put all images on it, and then i put it into database table,

so plz help me,

ASPX.cs Code is:

C#
protected void UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
   {
       string path = Server.MapPath("~/Upload/") + e.FileName;
       AjaxFileUpload1.SaveAs(path);
string file = e.FileName;


   }


if i upload three image then this code repeat three time, then how i put these image in one array or string array
Posted
Updated 13-Feb-13 19:04pm
v3
Comments
Guirec 13-Feb-13 1:24am    
Your problem is a bit more complex than it looks.
The simple way is to store your filenames in the user session object and then when the user submit the form you get all the filenames but that is a pretty poor design which can have a lot of side effects (eg: if the user has 2 browsers open to upload files for 2 different 'things')

The proper way to handle it is to store the filenames in a hidden field of the page. You can do so by registering a javascript function to the OnClientUploadComplete attribute of your FileUploader control.
Arun kumar Gauttam 13-Feb-13 5:08am    
if i use session or hidden field, then problem is still same,
protected void UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
string path = Server.MapPath("~/Upload/") + e.FileName;
AjaxFileUpload1.SaveAs(path);
session["id"] = e.FileName;


}

when second file is uploaded then,
first file of seesion is overrite by second file, and next, second is overrite to third file,

so plz suggest me that, what can i do,

i think a solution: that if i got total number of uploaded image(file),
at the start of UploadComplete event then i find max limit of array repetition,

so,
if Ajax File uploader Have any property Like this, then plz tell me,

Example:
int count= AjaxFileUpload1.count();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900