anita999 Posted April 10, 2007 Share Posted April 10, 2007 Could someone please recommend an example of uploading an image (jpeg or gif) using a form and doing the PHP validation of the image and then inserting it into a mysql table as a blob. I'm also interested in the validation part since I want to check whether a PHP script is inserted as part of the comments on the image and any other checks that can be performed to avoid insertion of the image into the DB in the case of a malicious image file. Thanks in advance, Anita Quote Link to comment Share on other sites More sharing options...
s0c0 Posted April 10, 2007 Share Posted April 10, 2007 Why not just upload the image to your file system and then have a column in your mysql table that acts as a link to the file? Most guru's on here will suggest this anyways. Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 11, 2007 Share Posted April 11, 2007 what do you mean by validation? as is size, or pixles etc? Quote Link to comment Share on other sites More sharing options...
anita999 Posted April 11, 2007 Author Share Posted April 11, 2007 By validation I mean, to check that the file is indeed a gif or jpeg etc and it is not some malicious file. Thanks Quote Link to comment Share on other sites More sharing options...
soycharliente Posted April 11, 2007 Share Posted April 11, 2007 http://us2.php.net/manual/en/function.strpos.php might help for checking to see what type of file it is. Also, http://us2.php.net/features.file-upload has a bit on type checking for uploaded files. Quote Link to comment Share on other sites More sharing options...
anita999 Posted April 11, 2007 Author Share Posted April 11, 2007 In one of the messages above, it was stated that it would be better to store the images in a filesystem and then have the DB link to the file. I can understand that storing it in the DB would take up a lot of space, but what would be strong reasons to store it in the filesystem instead of the DB directly? Is the assumption that the web sites that have a large subscriber base i.e. several hundred thousand subscribers would store the images in their filesytem instead of in the DB as a blob? Thank you, Anita Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 11, 2007 Share Posted April 11, 2007 well its easier to get is my understanding, but i might be wrong anyway, id simply put the location of the image in the database, and then put the image somewhere eles. just my opinion gdlk Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.