Re: [PHP] how 2 stroe images in Mysql Database using PHP
Suresh, suresh kumar wrote: i dont know how 2 store images in gif/jpeg format in Mysql Database.i also want 2 know PHP Code 2 store images in Mysql Database .reply me soon its very urgent . Storing the image in the database will result in a fairly large performance hit, but if you want to do that, it's your lookout. A quick search turned this up: http://www.zend.com/zend/trick/tricks-sept-2001.php David -- David Grant http://www.grant.org.uk/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] how 2 stroe images in Mysql Database using PHP
Hi, i dont know how 2 store images in gif/jpeg format in Mysql Database.i also want 2 know PHP Code 2 store images in Mysql Database .reply me soon its very urgent . A.suresh Conventional wizdom is that is it usually better/faster/more efficient to store images in the filesystem, and just store the PATH to those images in the database. There are certainly situations where storing the actual files in the database is required, and yours might be one. That being said, a quick google on the topic returned several relevant hits: http://www.google.com/search?as_q=store+jpg+mysql+php I encourage your own use of google as a programming and research aid, its fun and easy. Better than that, it reduces your need for asbestos underwear! JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how 2 stroe images in Mysql Database using PHP
Hey ... Ready example ... http://www.weberdev.com/get_example-4062.html Thanks, Richard On 1/16/06, suresh kumar [EMAIL PROTECTED] wrote: Hi, i dont know how 2 store images in gif/jpeg format in Mysql Database.i also want 2 know PHP Code 2 store images in Mysql Database .reply me soon its very urgent . A.suresh Send instant messages to your online friends http://in.messenger.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] how 2 stroe images in Mysql Database using PHP
You may also want to check this article : Saving Images in MySQL http://www.weberdev.com/ViewArticle-3.html Berber -Original Message- From: Richard Correia [mailto:[EMAIL PROTECTED] Sent: Monday, January 16, 2006 5:45 PM To: suresh kumar Cc: php-general@lists.php.net Subject: Re: [PHP] how 2 stroe images in Mysql Database using PHP Hey ... Ready example ... http://www.weberdev.com/get_example-4062.html Thanks, Richard On 1/16/06, suresh kumar [EMAIL PROTECTED] wrote: Hi, i dont know how 2 store images in gif/jpeg format in Mysql Database.i also want 2 know PHP Code 2 store images in Mysql Database .reply me soon its very urgent . A.suresh Send instant messages to your online friends http://in.messenger.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how 2 stroe images in Mysql Database using PHP
This one time, at band camp, David Grant [EMAIL PROTECTED] wrote: Storing the image in the database will result in a fairly large performance hit This is not always the case. Mostly this mis-nomer comes from using databases that use a secondary db for indexing or dont support true BLOB types like pgsql. I use MySQL to store images and did a few benchmarks and found it to be faster if I stored the db on a RAW partition, thus eliminating any file system overhead. The truth is that it is not slower, just folks dont know how to do it properly. When using MySQL with the db stored on the file system I found a 1 second difference of 100,000 accesses when benchmarked with ab. I also found this to be 0.5 seconds faster than storing the image on the file system and the url in the database, this was the _slowest_ method of access. The db access is a small part of the script so the performance penalty does not propogate linearly but remains constant so there is no exponetial slowdown. Below is a quicky to get you started Kind regards Kevin ?php ## ###### ### This is a very basic file upload ### ### script for my own purposes so ### ### ymmv ### ###### ## // just so we know it is broken error_reporting(E_ALL); ? html head titleStoring Images in DB/title /head body h3Basic upload of image to a database/h3 form method=post enctype=multipart/form-data Select Image File: input type=file name=userfile size=40 input type=hidden name=MAX_FILE_SIZE value=1000 input type=submit value=submit /form ?php // check if a file was submitted if(!isset($_FILES['userfile'])) { echo 'pPlease select a file/p'; } else { // upload the file upload(); // give praise and thanks to the php gods echo 'pThank you for submitting/p'; } // the upload function function upload(){ // include the config file include_once(config.php); if(is_uploaded_file($_FILES['userfile']['tmp_name'])) { // check the file is less than the maximum file size if($_FILES['userfile']['size'] $maxsize) { // prepare the image for insertion $imgData =addslashes (file_get_contents($_FILES['userfile']['tmp_name'])); // $imgData = addslashes($_FILES['userfile']); // get the image info.. $size = getimagesize($_FILES['userfile']['tmp_name']); // put the image in the db... // database connection mysql_connect(localhost, $username, $password) OR DIE (mysql_error()); // select the db mysql_select_db ($dbname) OR DIE (Unable to select db.mysql_error()); // our sql query $sql = INSERT INTO testblob ( image_id , image_type ,image, image_size, image_name) VALUES ('', '{$size['mime']}', '{$imgData}', '{$size[3]}', '{$_FILES['userfile']['name']}'); // insert the image if(!mysql_query($sql)) { echo 'Unable to upload file'; } } } else { // if the file is not less than the maximum allowed, print an error echo 'divFile exceeds the Maximum File limit/div divMaximum File limit is '.$maxsize.'/div divFile '.$_FILES['userfile']['name'].' is '.$_FILES['userfile']['size'].' bytes/div hr /'; }