I want to store images in to database using php script. how to store it?
I want to store images in to database using php script. how to store it?
Which database you are using are you using mysql or other database please give more details abotu the database.
Hi... Valendino...!!
I am using Mysql Database....!!So, in Mysql how can we store images..!! Not path whole image...!!
sample:
if(isset($_POST['submit'])){
$logos = $_POST['logo'];
if($logos==""){
$uploaddir ='../uploadPicture/header/';
$filename = $_FILES['new_image']['name'];
$uploadfile = $uploaddir . $filename;
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{
//print error message
$errors= $lang['pic_error'][$ver];
}
else{
$size=filesize($_FILES['new_image']['tmp_name']);
if ($size > MAX_SIZE*1024)
{
$error1 = $lang['limit'][$ver];
}
else{
if(move_uploaded_file($_FILES['new_image']['tmp_name'],$uploadfile))
{
echo " ";
}else{
echo $lang['cant_upload'][$ver];
}
$query = "insert into company_pic(company_pic) values('".$uploadfile."')";
$result = mysql_query($query);
}
}
}
else{
$uploaddir ='../uploadPicture/header/';
$filename = $_FILES['new_image']['name'];
$uploadfile = $uploaddir . $filename;
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{
//print error message
$errors= $lang['pic_error'][$ver];
}
else{
$size=filesize($_FILES['new_image']['tmp_name']);
if ($size > MAX_SIZE*1024)
{
$error1 = $lang['limit'][$ver];
}
else{
if(move_uploaded_file($_FILES['new_image']['tmp_name'],$uploadfile))
{
echo " ";
}else{
echo $lang['cant_upload'][$ver];
}
$query = "update company_pic set company_pic='".$uploadfile."' where id=$logos";
$result = mysql_query($query);
}
}
}
}
<form action="" method="post" enctype="multipart/form-data" id="something" class="uniForm">
<input name="new_image" id="new_image" size="30" type="file" class="fileUpload" />
<input type="hidden" name="logo" value="<?=$logo_ids?>" />
<INPUT type="reset" value="<?php echo $lang['reset'][$ver];?>">
<button name="submit" type="submit" class="submitButton"><?php echo $lang["savethis"][$ver];?></button>
</form>
good.............................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................
Never store your images in a database this is terribly slow!!
Its a bad bad bad idea to store images (or any files at that) directly into the database.
Any reason why you want to do this?
Nice useful coding sharing
not all the time, if you want to save filespace anyways lol, anyways i'm not sure if mysql supports image compression or not, but you could put a huge varchar var on mysql that runs along the lines of:etc. of each pixel representing each hex color code. then from there you can create a fresh PHP image off of that data by exploding the delimiter ":", then cachoa you got yourself an image that you can easily load from mysql :P, I could create a tutorial on that as well if anyone wants me tooCode:width:5:height:5:#323423:#323423:#456375
You need a blob field in binary in you MySQL database, then you can use a PHP script to read the image file with the file_get_contents() function and store the returned results in the blob field.
So you want to start a website and get prevalent? How about purchasing some website content database.
Bookmarks