Jun 8, 2016 09:20 AM
(This post was last modified: Jun 9, 2016 09:48 AM by Ciphered.)
Hello everyone, I am just starting out in ASP.NET and I am having a lot of fun however....
I am stuck on a really small problem that I can't seem to figure out how to get past.
Basically I am creating a web application, and in this case we are creating an announcement. It has a Title, Message, Date < and those all work fine.
I would like to also upload an image along with these details.
Since the databases that I have are scaffolded(created) from my Model.cs files is there a datatype in c# that can be used for Files, images more specifically.
I've read a couple dozen articles on how to go about this and have been going for about a week or so. I just can't seem to figure this out.
Below is the code that handles these functions...
Model:
Spoiler (Click to View)
Controller:
( I lied I can use IList<IFormFile> files as a parameter, there was a different bug that is fixed :) )
Spoiler (Click to View)
View Page:
Spoiler (Click to View)
ALL help is appreciated, thanks in advanced! 🤝
Current Status
Thanks for all the help so far, everyone has contributed valid information. I am still in the process of compiling this knowledge, and understanding how this whole process works.
I like the idea of using my Model to store the Image Contents, I have tried this using a byte array, however, when the information is posted, the byte[] = null.
Why is this so? Am I missing something? Is there a way to send the file from my View.cshtml to a IFormFile Parameter manually without Model Binding?
[img]http://s33.postimg.org/9n2vylrwv/Image_Help0.png[/img]
I am stuck on a really small problem that I can't seem to figure out how to get past.
Basically I am creating a web application, and in this case we are creating an announcement. It has a Title, Message, Date < and those all work fine.
I would like to also upload an image along with these details.
Since the databases that I have are scaffolded(created) from my Model.cs files is there a datatype in c# that can be used for Files, images more specifically.
I've read a couple dozen articles on how to go about this and have been going for about a week or so. I just can't seem to figure this out.
Below is the code that handles these functions...
Model:
Spoiler (Click to View)
Controller:
( I lied I can use IList<IFormFile> files as a parameter, there was a different bug that is fixed :) )
Spoiler (Click to View)
View Page:
Spoiler (Click to View)
ALL help is appreciated, thanks in advanced! 🤝
Current Status
Thanks for all the help so far, everyone has contributed valid information. I am still in the process of compiling this knowledge, and understanding how this whole process works.
I like the idea of using my Model to store the Image Contents, I have tried this using a byte array, however, when the information is posted, the byte[] = null.
Why is this so? Am I missing something? Is there a way to send the file from my View.cshtml to a IFormFile Parameter manually without Model Binding?
[img]http://s33.postimg.org/9n2vylrwv/Image_Help0.png[/img]
Leakedsource.com HF Rep / Thread updater



![[Image: PtCft6i.png]](https://i.imgur.com/PtCft6i.png)