Questions tagged [httppostedfile]

51 questions
25
votes
4 answers

HttpPostedFile.FileName - Different from IE

When I upload a file to a site using the ASP:File control the FileName property is different in IE and Firefox. In Firefox, it just provides the name of the file, but IE provides the full path to the file. I have worked around this by adding the…
Ryan Smith
  • 8,344
  • 22
  • 76
  • 103
22
votes
1 answer

What is the shortest way to get the string content of a HttpPostedFile in C#

I have an HttpPostedFile object and just need to extract the content of the posted file. I found this link but that's a very long process to just obtain a string with the content. Is there any shorter way? (Preferably, a one line instruction.)
yorch
  • 7,170
  • 8
  • 32
  • 38
14
votes
2 answers

C# - I cannot reference HttpPostedFileBase

I am using MVC .NET in a distributed environment with CSLA and I can reference HttpPostedFileBase from one of my web layers (eg Website.MVC), but I cannot reference HttpPostedFileBase from a separate layer (lets call it OtherLayer.Web). Any idea…
Teddy
  • 143
  • 1
  • 1
  • 4
12
votes
2 answers

Getting "Cannot access a closed file" errormessage when getting file from session

I have a asp.net FileUpload control. I can successfully upload file to store in session, but when I am tring to get its inputstream (I'm store file in HttpPosterFile) I'm getting error Cannot access a closed file tr.PostedFile //<==…
Jaztingo
  • 570
  • 1
  • 5
  • 15
8
votes
3 answers

FileUpload Contol not showing posted files

I am trying to upload multiple files on an aspx page using one FileUpload control. I've set the control to allow for multiple files: Now, on the click of a button I…
Carel
  • 2,063
  • 8
  • 39
  • 65
7
votes
1 answer

Maintain order of selected files in FileUpload with AllowMultiple=true

I have an control with the property AllowMultiple set to true:
Martina
  • 1,852
  • 8
  • 41
  • 78
4
votes
4 answers

Getting the original files create date upon upload

We have a process in place that uploads files to our website. It has become important to the users to be able to see when those files were created. I'm looking for a way to extract the original create date from the HttpPostedFile. If anyone has…
Jon
3
votes
2 answers

Upload file in ASP.NET MVC (Again!)

I have a problem with uploading file in asp.net mvc 2. My controller function's parameter is a FormCollection type. Because the fields are too numerous, I can't separate each field as a parameter. I have 2 upload file fields in my form. How can I…
Jalal
  • 6,594
  • 9
  • 63
  • 100
3
votes
4 answers

Invalid Cast Exception in HttpFileCollection

I have an extension method below, but when I run this, the foreach gives me InvalidCastException and it says * Unable to cast object of type 'System.String' to type 'System.Web.HttpPostedFile'. Code : public static List
Tarik
  • 79,711
  • 83
  • 236
  • 349
2
votes
1 answer

Moq'ing HttpPostedFile for 3rd Party API

I'm building a custom module by extending ActiveSocial for DotNetNuke and using ActiveSocial's API that I have no control over... and I'm trying to unit test my code (using C#). In using this API - I can save images to AmazonS3 by calling their…
ajwaka
  • 608
  • 1
  • 7
  • 12
2
votes
1 answer

Java library for reading multipart/form-data http body containing multiple files

Basically, the following is what the format of data look like (it should follow HTTP standard format) Content-Type: multipart/form-data;…
tom
  • 14,273
  • 19
  • 65
  • 124
2
votes
4 answers

File is locked after HttpPostedFile SaveAs(LocationOnServer)

I have an aspx webpage that uses as handler to save uploaded files via swfupload I am saving the file on the server like this: HttpPostedFile uploadedFile = Request.Files["Filedata"]; uploadedFile.SaveAs(LocationOnServer); the problem is that after…
kleinohad
  • 5,800
  • 2
  • 26
  • 34
2
votes
2 answers

ASP.NET MVC passing Model *together* with files back to controller

Ok, I've been going at this for several hours and I simply cannot find the solution. I want to get some data from my user. So first, I use a controller to create a view which receives a Model: public ViewResult CreateArticle() { Article…
2
votes
1 answer

Edit View Model Binding with HttpPostedFile

I have a ViewModel: public HttpPostedFileBase File { get; set; } public string Notes { get; set; } In the Create view, I have an that binds the HttpPostedFile to the model. So far, so good. My problem…
2
votes
1 answer

How should i save a HttpPostedFile

Situation, a user MAY upload a file and MAY trigger the spam filter. If it does trigger the spam filter i save all the post data and show a captcha. If the 'bot' doesnt succeed by the time the session times out the HttpPostedFile data (which…
user34537
1
2 3 4