Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I have created a "Create" view in MVC application and on that I have 4 different sections, i.e., ID1, ID2, ID3 and ID4, to upload the respective images. I have uploaded successfully.

Now I have to update the records for that I have created a "Edit" view i am displaying the images from url where I am storing the Images. Now when I am updating only one Image in HttpPostedFile of that image I am getting the value, But in other three HttpPostedFile I am getting the null value.

How to resolve this issue?

Thanks
Posted
Comments
John C Rayan 7-Jan-16 7:24am    
Can you show us your code?
DT_2 8-Jan-16 0:15am    
There are 4 different browse buttons like bellow :
=====View Code====
<input type="file" name="file1"/>
<input type="file" name="file2"/>
<input type="file" name="file3"/>
<input type="file" name="file4"/>

====Action Code====
public ActionResult Edit(HttpPostedFileBase file1, HttpPostedFileBase file2, HttpPostedFileBase file3, HttpPostedFileBase file4){
----here is my code to save the file----
}

now when I update only file1 i get the null in other, i.e., in file2, file3 and file4.
John C Rayan 8-Jan-16 4:22am    
This is how input file works. What you are getting is right. What's the issue here.
DT_2 8-Jan-16 7:26am    
If I update only file1, than I am getting proper value for file1, but in file2, file3, file4 I am getting null value. But there is the previous values stored and I am displaying the images for the same. This condition is in the arising in Edit Post Action.

1 solution

I would recommend to follow this article and shout if you have any issues

Multiple File Upload in MVC[^]
 
Share this answer
 

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