shah_ankitb Posted June 12, 2007 Share Posted June 12, 2007 Hello Friends, Is it better to store images in Database or in Folder?.Storing Images in Database it stores in Binary Form.So will it make my DB more larger.So what is the convinent way to store images. http://www.fornewbie.com/article/php/uploa..._tutorial..html From the above link u can see that how can we store images in DB & Retrieve Link to comment Share on other sites More sharing options...
vijay Posted June 12, 2007 Share Posted June 12, 2007 Hi.. you can refer the following 2 links..It'll show you both advantage as well as disadvantage.. http://databases.aspfaq.com/database/shoul...filesystem.html http://www.datanamic.com/support/storeimag...hedatabase.htmlRegards,Vijay Link to comment Share on other sites More sharing options...
justsomeguy Posted June 12, 2007 Share Posted June 12, 2007 It's faster to store images as files. It takes some time to get the data out of the database. As for convenience and which is "best", that's up to your situation. Link to comment Share on other sites More sharing options...
Skemcin Posted June 12, 2007 Share Posted June 12, 2007 There are many pros/cons to storing the binary information in the database versus keeping the file on a server. As its been stated, each scenario is different. Your database server and software are second to the justification of implementing the functionality. One of the most common "pros" for doing it is the higher level of access security you get which is often combined with the how mobile the application is with everything in the DB. Moving a site from one server or host to another might be easier since its just the code and the database. You also have more control over orphaned files as long as your SQL is in order.Again, as its been said, your application requirements should dictate your decision. The technology these days is pushing performance concerns lower on the list of "cons" - but you'd have to have a god handle on what file sizes you expect to be databased. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 12, 2007 Share Posted June 12, 2007 The technology these days is pushing performance concerns lower on the list of "cons" - but you'd have to have a god handle on what file sizes you expect to be databased.That's a good point, you absolutely need a god handle. That way if anything goes wrong, you just pull the god handle. It's kind of like a panic button, except its a handle. Link to comment Share on other sites More sharing options...
smartalco Posted June 12, 2007 Share Posted June 12, 2007 as for wether or not its the best way, i left the files on the server and put the urls of the files in the DB $dir = "whatever_dir/";$files = scandir($dir);foreach(files as $photo) { if(is_dir($photo) == false && $photo != ".DS_Store") { //the .DS_Store part is a mac thing $photo_url = $dir . $photo; mysql_query("INSERT INTO photos (photo_url) VALUES ('$photo_url')"); }} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.