How do you upload and resize an image with PHP?

<form enctype="multipart/form-data" action="add.php" method="POST">

<input type="file" name="photo"><br>

<input type="submit" name="sub" value="Add" action="page">

<input type='hidden' id='Id' value='{$Id} name="id"/>


/////////////////////php coding


//////include these files

require "includes/common.php";


global $global_config;

$objCommonQueries = new CommonQueries();

$employee_attachments = "employee_attachments";///table name

$target = $global_config["doc_path"];

$target = $target .basename( $_FILES['uploaded']['name']) ;


if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))


echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";




echo "Sorry, there was a problem uploading your file.";


$uploaded_size = $_FILES['uploaded']['size'];

if ($uploaded_size > 350000)


echo "Your file is too large.<br>";



$currentdate = date('Y-M-D h:i:s');

$filename = $_FILES['uploaded']['name'];

$id = '2';

you can save these uplaoad image in which database you need and can display


//fetch the image from database and assign to smarty variable $getimage

<div style="width:150px; float:left;margin-left:20%;margin-bottom:5px;">

<div><img src="{$getimage}" style="width:125px; float:left; height:175px; margin-left:9%;margin-bottom:5px; background:#f2f2f2; border:1px solid #cccccc"> &nbsp; </div>

<div align="center"> <input type="button" class="button" value="Browse" /></div>