Hi guys, I am uploading member’s picture into my database. However, there are instances that the member will not upload its photo. In this case, I’d like to upload instead a picture that is stored in my web app’s folder. How am I going to get the picture and store it in my database.
setting it null is the best option. that way any change on that generic image could be reflected on all.
if you need to protect image, there are better options. saving image on DB is not much of a good choice.
If the posted file is null, instead open a FileStream object for the file you’d like to insert, and read bytes from that.
Or better yet, introduce logic into your app that if the column with the image data is null, display the image from the file system, preferably in an already public place. Then you’re not needlessly duplicating data.
There are no setters for the upload control, guess cos it’s seen as a security risk. As such I don’t think you’ll be able to change the file for upload from your code behind. You may have to look for a different approach to handling the problem, like displaying the default image from file system
I’ve never been a huge fan of storing images in a database. Normally, I just save the image to a specified location on the server and save the file path to the database.