I am using asp.net mvc and have a section where a user can upload images. I am wondering where should I store them.
I was following this tutorial and he seems to store it in the app_data. I however read another person say it should only hold your database.
So not sure what the advantages are for using app_data. I am on a shared hosting so I don’t know if that makes a difference.
Edit
I am planning to store the path to the images in the database. I will be then using them in a image tag and rendering them to the user when they come to my site. I have a file uploader that only will expect images(check will be client and server)
The tutorial is a simple example – and if you read the comments, the original code just saved to an
uploadsdirectory, noapp_datain sight.It was changed to
app_databecause that’s a special folder – one that will not allow execution of code.And you have understood correctly –
app_datais really there for holding file based databases. That’s the meaning of the folder. As such saving images into it doesn’t feel like the right thing to do.If you are certain only images will get uploaded (and you control that), I would suggest an
/uploadsdirectory – a reserved location for images that also will not allow code execution (something that you should be able to control via IIS).