I am trying to upload multiple files.. if he/she wants.. when they click on upload more files then want to display another upload .. and when when click on submit then want to insert data.. insert is not problem .. problem is when they click on upload more
files then how to upload multiples
What if you try System.IO.Path rather than just Path? (or make sure you have a using System.IO;)
You really want the user to explictely load a single file at a time. With 4.5 you can take advantage of HTML 5 and let the user to select multiple files with a single control:
What if you try System.IO.Path rather than just Path? (or make sure you have a using System.IO;)
You really want the user to explictely load a single file at a time. With 4.5 you can take advantage of HTML 5 and let the user to select multiple files with a single control:
What if you try System.IO.Path rather than just Path? (or make sure you have a using System.IO;)
You really want the user to explictely load a single file at a time. With 4.5 you can take advantage of HTML 5 and let the user to select multiple files with a single control:
and what if file is in different locations so when how i select files from different location/ thats why i want individual upload for every file.. when user click on upload more files then want to display file upload
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
suppose there is file upload control.. when we select file by clicking on browse and then click on upload then file name with extension i.e. abc.doc should be display ... then when we use again same file upload and click on browse and select another file
then file will be display i.e. xyz.pdf.. so there is two files abc.doc and xyz.doc .. so this is want to do .. i want to upload files and display these uploaded files
UPDATE
for this i try this
protectedvoidLinkButton1_Click(object sender,EventArgs e){
fileuploadd(FileUpload1.FileName);}publicvoid fileuploadd(string filename){try{HttpFileCollection hfc =Request.Files;for(int i =0; i < hfc.Count; i++){HttpPostedFile hpf = hfc[i];if(hpf.ContentLength>0){SMSEntities s =newSMSEntities();
uploaded_file u =new uploaded_file();{
u.fileupload = filename;}
s.uploaded_file.Add(u);
s.SaveChanges();}//hpf.SaveAs(Server.MapPath("upload") + "\\" + System.IO.Path.GetFileName(hpf.FileName));Response.Write("<b>File: </b>"+ hpf.FileName+" <b>Size:</b> "+ hpf.ContentLength+" <b>Type:</b> "+ hpf.ContentType+" Uploaded Successfully <br/>");}}catch(DbEntityValidationException e){foreach(var eve in e.EntityValidationErrors){Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
eve.Entry.Entity.GetType().Name, eve.Entry.State);foreach(var ve in eve.ValidationErrors){Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
ve.PropertyName, ve.ErrorMessage);}}throw;}}
so when i select file and click on upload then file name is display .. but when i select again file and click on upload then 1st file name is disappear and 2nd file name is display where as i want both ..
so how i display both filenames ... and when click on submit then record files should be inserted in tables individually i am done with this
but first i want to display both filename and then these two files should be inserte in table with indivually record like this
so how i display both filenames ... and when click on submit then record files should be inserted in tables individually i am done with this
but first i want to display both filename and then these two files should be inserte in table with indivually record like this
As for this issue, it seems that you have create a
new thread about this issue. You could refer to my reply in that thread and use a global list to store the upload file name.
When you select file again, you could insert the file name into the list. Then, use the String.Join method to join the file name and display them.
Besides, you could also use ViewState or Session to store the file name.
Best regards,
Dillion
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
239 Points
1074 Posts
Upload multiples file
Dec 22, 2016 11:52 AM|Capricon User|LINK
I am trying to upload multiple files.. if he/she wants.. when they click on upload more files then want to display another upload .. and when when click on submit then want to insert data.. insert is not problem .. problem is when they click on upload more files then how to upload multiples
HTML
All-Star
48300 Points
18003 Posts
Re: Upload multiples file
Dec 22, 2016 12:11 PM|PatriceSc|LINK
Hi,
What if you try System.IO.Path rather than just Path? (or make sure you have a using System.IO;)
You really want the user to explictely load a single file at a time. With 4.5 you can take advantage of HTML 5 and let the user to select multiple files with a single control:
http://www.c-sharpcorner.com/uploadfile/99bb20/upload-multiple-files-using-fileupload-control-in-asp-net-4/
Member
239 Points
1074 Posts
Re: Upload multiples file
Dec 22, 2016 12:19 PM|Capricon User|LINK
ok i try this but when i select browse and try to select multiple files then i unable to select files .. this select only single file
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFiles)
{
foreach (HttpPostedFile uploadedFile in FileUpload1.PostedFiles)
{
uploadedFile.SaveAs(System.IO.Path.Combine(Server.MapPath("~/Images/"),
uploadedFile.FileName));
Span1.Text += String.Format("{0}<br />", uploadedFile.FileName);
}
}
Member
239 Points
1074 Posts
Re: Upload multiples file
Dec 23, 2016 06:21 AM|Capricon User|LINK
and what if file is in different locations so when how i select files from different location/ thats why i want individual upload for every file.. when user click on upload more files then want to display file upload
Member
239 Points
1074 Posts
Re: Upload multiples file
Dec 24, 2016 08:58 PM|Capricon User|LINK
any help please
All-Star
45489 Points
7008 Posts
Microsoft
Re: Upload multiples file
Dec 27, 2016 07:13 AM|Zhi Lv - MSFT|LINK
Hi Bakhtawar Ashiq,
As for this issue, you could try to use multiple upload control:
http://www.aspsnippets.com/Articles/Upload-multiple-files-with-ASPNet-45-FileUpload-control-in-Visual-Studio-2012-and-2013.aspx
https://www.codeproject.com/articles/667604/upload-multiple-files-in-asp-net
Also, you could try to use AjaxFileUpload control, please refer to the following links:
http://www.aspsnippets.com/Articles/Multiple-files-upload-with-Drag-and-Drop-and-Progress-bar-using-ASPNet-AJAX-AjaxFileUpload-control.aspx
http://www.c-sharpcorner.com/article/ajax-control-toolkit-tutorial-ajaxfileupload-part-three/
Best regards,
Dillion
Member
239 Points
1074 Posts
Re: Upload multiples file
Dec 27, 2016 11:30 AM|Capricon User|LINK
suppose there is file upload control.. when we select file by clicking on browse and then click on upload then file name with extension i.e. abc.doc should be display ... then when we use again same file upload and click on browse and select another file then file will be display i.e. xyz.pdf.. so there is two files abc.doc and xyz.doc .. so this is want to do .. i want to upload files and display these uploaded files
UPDATE
for this i try this
so when i select file and click on upload then file name is display .. but when i select again file and click on upload then 1st file name is disappear and 2nd file name is display where as i want both ..
so how i display both filenames ... and when click on submit then record files should be inserted in tables individually i am done with this
but first i want to display both filename and then these two files should be inserte in table with indivually record like this
1 abc.docx
2 def.docx
All-Star
45489 Points
7008 Posts
Microsoft
Re: Upload multiples file
Dec 29, 2016 09:16 AM|Zhi Lv - MSFT|LINK
Hi Bakhtawar Ashiq,
As for this issue, it seems that you have create a new thread about this issue. You could refer to my reply in that thread and use a global list to store the upload file name.
When you select file again, you could insert the file name into the list. Then, use the String.Join method to join the file name and display them.
Besides, you could also use ViewState or Session to store the file name.
Best regards,
Dillion