c# - FileUpload uploads 1 file multiple times -


When I try to upload multiple files, all the files are copied all of the one when I say That means copies means I have different file names, different file extensions, but the same picture in all the images.

Example:

I select four files, 2 PNG, 2 different sizes of JPG when I upload them, they come like this:

  • 1.jpg - 256kb
  • 2.jpg - 256kb
  • 3.p ng - 256kb
  • 4.png - 256 Kb

I am doing this when it is happening. Response. Displays the light file as different size, but they are saved as a single file.

  foreach (HttpPostedFile file in FileUpload1.PostedFiles) {// Debugging only - I know the answer. Bad to use the feedback. Writite (file.FileName + "-" + file.ContentLength + "& lt; br & gt;"); // Normally to set a server, debug to FileUpload1.SaveAs C (Path.Combine ("C: \\ Uploaded"), file.FileName); }  

Output:

  1.png - 270587 2.png - 261286 3.JPG - 1309586 4.JPG - 912675  

So it knows that they are different files but it does a file four times any thoughts why?

  FileUpload1.SaveAs (Path.Combine ("C: \\ upload"), File .FileName);  

will not work You need to work on the file object which crosses through the FileUpload1.PostedFiles list.

Use file.SaveAs (...) instead.

Take a look: an example / for more information.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -