httppostedfile

Getting “Cannot access a closed file” errormessage when getting file from session

跟風遠走 提交于 2019-12-14 00:32:51
问题 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 //<== HttpPostedFile; byte[] byteArray = null; using (var binaryReader = new BinaryReader(tr.PostedFile.InputStream)) { byteArray = binaryReader.ReadBytes(tr.PostedFile.ContentLength); } 回答1: add this to your web.config file <system.web> <httpRuntime

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

冷暖自知 提交于 2019-12-12 17:18:34
问题 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 newArticle = new Article(); ImagesUploadModel dataFromUser = new ImagesUploadModel(newArticle); return View(dataFromUser); } Then, I have the view: <asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server"> <h2>AddArticle</h2> <%

File is locked after HttpPostedFile SaveAs(LocationOnServer)

 ̄綄美尐妖づ 提交于 2019-12-11 01:54:45
问题 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 I save the file the file remain locked (by w3wp.exe) until I restart the IIS. Is there any way to release the file after save? Thanks 回答1: I have dealt with the same situation in the past. You need to run your application pool under a domain

Getting the original files create date upon upload

六月ゝ 毕业季﹏ 提交于 2019-12-08 07:56:52
问题 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 an idea for me I'd really appreciate it (I'm a bit stumped at this point). 回答1: You don't have access to the date the file was created on the client. You can use Fiddler to validate this. I believe the only data you'll see being posted is the filename

Getting “Cannot access a closed file” errormessage when getting file from session

醉酒当歌 提交于 2019-12-05 02:05:34
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 //<== HttpPostedFile; byte[] byteArray = null; using (var binaryReader = new BinaryReader(tr.PostedFile.InputStream)) { byteArray = binaryReader.ReadBytes(tr.PostedFile.ContentLength); } add this to your web.config file <system.web> <httpRuntime useFullyQualifiedRedirectUrl="true" maxRequestLength="15360" requestLengthDiskThreshold="15360"/> </system.web> http:/

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

ぃ、小莉子 提交于 2019-12-04 16:04:10
问题 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.) 回答1: var str = new StreamReader(postedFile.InputStream).ReadToEnd(); StreamReader.ReadToEnd 来源: https://stackoverflow.com/questions/10344449/what-is-the-shortest-way-to-get-the-string-content-of-a-httppostedfile-in-c-shar

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

青春壹個敷衍的年華 提交于 2019-12-03 10:13:57
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.) Leniel Maccaferri var str = new StreamReader(postedFile.InputStream).ReadToEnd(); StreamReader.ReadToEnd 来源: https://stackoverflow.com/questions/10344449/what-is-the-shortest-way-to-get-the-string-content-of-a-httppostedfile-in-c-shar

C# - I cannot reference HttpPostedFileBase

佐手、 提交于 2019-11-30 08:13:09
问题 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 on what I need to do to be able to call HttpPostedFileBase ? I am able to use HttpPostedFile in both layers - should I just use this instead? The assembly references are basically the same - in Website.MVC I have: namespace Website.Mvc.Controllers {

C# - I cannot reference HttpPostedFileBase

流过昼夜 提交于 2019-11-29 06:18:27
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 on what I need to do to be able to call HttpPostedFileBase ? I am able to use HttpPostedFile in both layers - should I just use this instead? The assembly references are basically the same - in Website.MVC I have: namespace Website.Mvc.Controllers { using System; using System.Collections; using System.Collections.Generic; using System.Web.Mvc; using

HttpPostedFile.FileName - Different from IE

∥☆過路亽.° 提交于 2019-11-28 07:21:08
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 code: Dim FileName As String = file.FileName If FileName.LastIndexOf("\") > 0 Then FileName = FileName.Substring(FileName.LastIndexOf("\") + 1) End If But I'm not sure why that would be different between the different browsers. Does anyone know the reason for this? Thanks. This is a security/privacy concern, firefox/mozilla is doing it right and you