I am working on an application for a person to upload a word or pdf document and saving the path to a database and make that downloadable to an admin. My recommended approach, if possible - Refactor your code to not use HttpPostedFileBase, and go with, say, Stream instead. The file uploads to the directory file fine bu. HttpPostedFileBase filedata 0 filedata.SaveAs('\Path ame.jpg') But I use the InputStream of HttpPostedFileBase, so the image 180 Grand from portrait is rotated to landscape mode.This should be simple enough, it's only a small class, and depending on your code making use of it, you might not even have to implement all methods. Implement your own inheriting class of base HttpPostedFileBase.Find a factory, or some other method in System.Web that will construct a HttpPostedFile instance for you (my suspicion is you won't find that).constructor input.īut here's the rub, the constructor for HttpPostedFile is internal, so outside of the System.Web library, you're not constructing an instance directly. In previous version of ASP.NET an uploaded file was performed by instance of, but in the ASP.NET Core this has been replaced by. HttpPostedFileBase postedFile httpContext.Request. ![]() Now, if you absolutely must have an instance of HttpPostedFileBase, here's what you're up against. When working with posted files make sure to use Path.GetFileName for extrancting the posted file name. In the example by Pommy, perhaps an input of Stream would be more appropriate? Firstly, as in the other question link to, having a method that requires a HttpPostedFileBase as an input, and then requires you to send a file not automatically transferred as a HttpPostedFileBase, suggests you need to refactor the method.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |