HOW TO STORE AN IMAGE IN PHP

STEP 1: CREATE HTML FORM FIRST
<form action=”filename.php” enctype=”multipart/form-data” method=”post”>

<table width=1>
<tbody><tr>
<td>
<input name=”uploadedimage” type=”file”>
</td>

</tr>

<tr>

<td>
<input name=”Upload Now” type=”submit” value=”Upload”/>
</td>
</tr></tbody></table></form>

STEP 2: CREATE MYSQL TABLE

CREATE TABLE images(images_id INT NOT NULL AUTO_INCREMENT,images_path VARCHAR(400) NOT NULL,submission_date DATE,PRIMARY KEY (images_id));

STEP 3: CREATE PHP-MYSQL CONNECTION

<?php
$host=”localhost”;
$databasename=”your database name”;
$user=”root”;
$pass=””;

$conn=mysql_connect($host,$user,$pass);

if($conn)
{
$db_selected = mysql_select_db($databasename);
if (!$db_selected) {
die (‘Error: ‘ . mysql_error());
}
}
else
{
die(‘Not connected : ‘ . mysql_error());
}
?>
STEP 4: PHP CODE TO STORE IMAGE IN MYSQL

<?php
include(“yourdatabasefilename.php”);

function GetImageExtension($imagetype)
{
if(empty($imagetype)) return false;
switch($imagetype)
{
case ‘image/bmp': return ‘.bmp';
case ‘image/gif': return ‘.gif';
case ‘image/jpeg': return ‘.jpg';
case ‘image/png': return ‘.png';
default: return false;
}
}

if (!empty($_FILES[“uploadedimage”][“name”])) {

$file_name=$_FILES[“uploadedimage”][“name”];
$temp_name=$_FILES[“uploadedimage”][“tmp_name”];
$imgtype=$_FILES[“uploadedimage”][“type”];
$ext= GetImageExtension($imgtype);
$imagename=date(“d-m-Y”).”-“.time().$ext;
$target_path = “images/”.$imagename;

if(move_uploaded_file($temp_name, $target_path)) {

$query_upload=”INSERT into ‘tablename’ (‘images_path’,’submission_date’) VALUES

(‘”.$target_path.”‘,'”.date(“Y-m-d”).”‘)”;
mysql_query($query_upload) or die(“error in $query_upload == —-> “.mysql_error());

}else{

exit(“Error While uploading image on the server”);
}

}

?>

The Employment Bond is basically an agreement which the company and the employee enter into which among the other terms contained therein states that in consideration of the training given to the Employee and the money spent by the company in imparting such training, the Employee will remain in the services of the company for a particular period.

Find out positive reviews received by SynapseIndia for their PHP website development.

Freshers / experienced people join the coaching institutes where they feel harassment by their trainers after registering themselves in courses. But SynapseIndia is not providing any course. Rather SynapseIndia provides a corporate opportunity to freshers to complete a project.