pls
how to save image in mysql using php codehow to save picture of any person in our database using php as fronten
Page 1 of 1
6 Replies - 7590 Views - Last Post: 26 April 2010 - 12:30 PM
Replies To: how to save image in mysql using php code
#2
Re: how to save image in mysql using php code
Posted 11 January 2010 - 05:55 AM
Save the path to the image in the database, not the image. Saving the image will only slow things down.
#3
Re: how to save image in mysql using php code
Posted 11 January 2010 - 07:13 AM
Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:
- Post the code you're having problems with
- Post the exact error you're receiving, if you are receiving one
- If no error explain what the code is doing versus what you want it to do
- Post your question in the body of your post, not the description field
#4
Re: how to save image in mysql using php code
Posted 13 January 2010 - 01:21 AM
you can save your image in database instead of saving the path in database.
first thing,
use longblob datatype in mysql table:
ex:
create table image_storing(filetype varchar(100),image longblob);
in the image column ur image has been saved.
php code:
first retrive the image path:
eg:
html code:
php code:in form_save.php
*** MOD EDIT: Added code tags. Please
***
first thing,
use longblob datatype in mysql table:
ex:
create table image_storing(filetype varchar(100),image longblob);
in the image column ur image has been saved.
php code:
first retrive the image path:
eg:
html code:
<form name="image_tr" action="form_save.php" enctype="multipart/form-data" method="post"> <input type="file" name="image_file" > </form>
php code:in form_save.php
if($_FILES['image_file'][tmp_name]!="")
{
/* moving the image from tempdirectory to specified driectory*/
move_uploaded_file($_FILES[''image_file'']['tmp_name'],"image/".$_FILES[''image_file'']['name']);
$image_type=$_FILES['image_file']['filetype'];
$image="image/".$_FILES[''image_file'']['name'];
/* image stroing in mysql */
$sql="insert into image_storing values('$image_type','$image')";
$execute_sql=mysql_query($sql) or die("could not save");
if($execute_sql)
{
unlink($image);/* to delete the image from folder*/
}
}
*** MOD EDIT: Added code tags. Please
#5
Re: how to save image in mysql using php code
Posted 26 April 2010 - 06:16 AM
I will try this code
This post has been edited by fresher123: 26 April 2010 - 06:17 AM
#6
Re: how to save image in mysql using php code
Posted 26 April 2010 - 07:57 AM
#7
Re: how to save image in mysql using php code
Posted 26 April 2010 - 12:30 PM
You should never upload the image to the database. It will take up a lot of space and slow down your queries. What you should do, however, is follow the original set of instructions that were given to you by CTphpnwb.
Also when choosing an answer, that little green bar below the user picture with 'Reputation: *' in it is something to be noted. A high reputation signifies credibility. You should weigh their answers heavier.
Also when choosing an answer, that little green bar below the user picture with 'Reputation: *' in it is something to be noted. A high reputation signifies credibility. You should weigh their answers heavier.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote








|