PDA

View Full Version : Dreamweaver form upload with text


neodev
01-20-2015, 10:57 AM
Hi there,
I build a form with 2 text field and one upload field (image). It send data into a mysql db called "images" with a table called "pictures" with 4 fields:"id", "name", "surname" and "immagine". The script resize the image on upload into 3 different format (600px,200px,100px) and upload them into 3 folder:large, small and micro.It work in a excellent way (for the resize goal) but I'm unable to store the "name and surname" field and the "path/image name"into the mysql db.Also, I'm unable to upload the next image. Please, could you help me? Thanks.





<?php include('connect.php');?>


<?php

// function to get file extension
function getExtension($str) {

$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
// define max file size, change to suit your own maximum file size
define ("MAX_SIZE","10000");
$errors=0;


//get the original file from form
if($_SERVER["REQUEST_METHOD"] == "POST")
{


// from your upload form

$image = $_FILES["file"]["name"];// from your upload form
$uploadedfile = $_FILES['file']['tmp_name'];// from your upload form
// check for correct file extension
if ($image)
{
$filename = stripslashes($_FILES['file']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{
echo ' Unknown Image extension! ';// build your own error handling here
$errors = 1;
}
// check for correct file size
else
{
$size=filesize($_FILES['file']['tmp_name']);

if ($size > MAX_SIZE*1024)
{
echo "You have exceeded the size limit";// build your own error handling here
$errors = 1;
}
// check which extension we have and create file
if($extension=="jpg" || $extension=="jpeg" )
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
}
else if($extension=="png")
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefrompng($uploadedfile);
}
else
{
$src = imagecreatefromgif($uploadedfile);
}
//resize image and create thumbs and small thumbs
list($width,$height)=getimagesize($uploadedfile);
//for main images, this keeps the width at 300px regardless of portrait or landscape
$newwidth=600;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);
//for thumbnails, change the $newwidth variable to what ever size you need
if($width > $height){//landscape
$newwidth1=200;
$newheight1=($height/$width)*$newwidth1;
$tmp1=imagecreatetruecolor($newwidth1,$newheight1) ;
}elseif($width < $height){//portrait
$newheight1=100;
$newwidth1=($width/$height)*$newheight1;
$tmp1=imagecreatetruecolor($newwidth1,$newheight1) ;
}
//for smaller thumbnails, my site required this smaller thumb. Delete this section if you dont need it
if($width > $height){//landscape
$newwidth2=50;
$newheight2=($height/$width)*$newwidth2;
$tmp2=imagecreatetruecolor($newwidth2,$newheight2) ;
}elseif($width < $height){//portrait
$newheight2=50;
$newwidth2=($width/$height)*$newheight2;
$tmp2=imagecreatetruecolor($newwidth2,$newheight2) ;
}
// create new resized files
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$ne wheight,$width,$height);

imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$ newheight1,$width,$height);

imagecopyresampled($tmp2,$src,0,0,0,0,$newwidth2,$ newheight2,$width,$height);
//declare destinations
$filename = "large/". $_FILES['file']['name'];
$filename1 = "small/". $_FILES['file']['name']; // your destination paths here
$filename2 = "micro/". $_FILES['file']['name'];
//write files to folders
imagejpeg($tmp,$filename,100);
imagejpeg($tmp1,$filename1,100);
imagejpeg($tmp2,$filename2,100);
//destroy temps to save memory
imagedestroy($src);
imagedestroy($tmp);
imagedestroy($tmp1);
imagedestroy($tmp2);
}
}
}

//If no errors registered, insert file name into database and print the success message
if(isset($_POST['invia']) && !$errors)
{
mysql_query("INSERT INTO pictures VALUES ('$_POST[nome],'$src)");

$success = "Image Uploaded Successfully!";
}
//////////////////////////////////////////////////select file names from database

?>









<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Upload Image Files and Resize</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="upload" enctype="multipart/form-data" method="post" action="upload.php">
<p>Name :</p>
<p>
<label for="name"></label>
<input type="text" name="name" id="name">
</p>
<p>Surname:</p>
<p>
<label for="surname"></label>
<input type="text" name="surname" id="surname">
</p>
<p>Image:</p>
<p>
<input type="file" name="file" id="file" >
</p>
<p>
<input type="submit" name="invia" id="invia" value="Submit">
</p>
</form>
</body>
</html>

edbr
01-21-2015, 01:04 AM
quick look only but comment reads
// create new resized files

//declare destinations
$filename = "large/". $_FILES['file']['name'];
$filename1 = "small/". $_FILES['file']['name']; // your destination paths here
$filename2 = "micro/". $_FILES['file']['name'];



so they are the paths that you want inserting into your database

neodev
01-21-2015, 07:53 AM
Hi edbr,
thanks for your reply.
Yes, I need to put the three images path into database , but the question is that I can't insert the other 2 field into the database (name e surname).
The easyphp server (where I test this script), give me back always the same error in the mysql_query:
mysql_query("INSERT INTO pictures VALUES ('$_POST[nome],'$src)");

Thanks for your help.

neodev
01-21-2015, 08:02 AM
Just change the "mysql_query" in this way:

mysql_query("INSERT INTO pictures VALUES ('name','surname','src)");

No more error is displayed on the page preview, but still not insert nothing into the db :-(

edbr
01-22-2015, 12:03 AM
mysql_query("INSERT INTO pictures (name.surname,image) VALUES ('name','surname','src)");
try that, edit to your datanase firld names

neodev
01-22-2015, 08:36 AM
I really thank you for support. I have insert your code: no more error when I test the page. The pictures are upload perfectly in the three folder with resized formats. But the data insert into "name and surname" field are not into the database. A this point, I start thinking about a "phpMyadmin" problem. Because when I tested other form, sometimes the data appear into phpMyadmin, others no. I use "EasyPHP-DevServer-14.1VC11". Please, have you some advice for me?
Thanks again, I'll try totest again

neodev
01-22-2015, 04:57 PM
Hi edbr,
First of all, I unistall easyphp and install wamp server. I make several test on simple database connection and everything is fine.
I tryed several times to edit the code as you told me, but nothing. As I said, the resize script work great, but I can't send the data into the db.
Hope you can help me. Thanks.

neodev
01-22-2015, 06:08 PM
I found a tutorial on the net to build what I need. Now I need to include only the resize script into the "cone_noti.php" file. Hope you can help me.

The form ("insertanoti.php"):


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Insertar</title>
</head>

<body>
<h1>Insertar noticia</h1>
<form action="cone_noti.php" method=post enctype="multipart/form-data">


<label>
TITULO:
<input name="titulo" type="text" id="titulo">
</label>
<br>

<label>
FECHA:
<input name="fecha" type="text" id="fecha">
</label>
<br>

<label>
DESCRIPCION:
<input name="descripcion" type="text" id="descripcion" value="" />
</label>
<br>
<label>
NOTICIA:
<input name="noticia" type="text" id="noticia" value="" />
</label>
<br>


Elija Foto de Perfil<br>


<input type="file" name="imagen">
<input type="submit" value="Guardar">
</form>
<p>Nota: El formato de la fecha (aņo/mes/dia)</p>
<br />
<a href="index.php">Atras</a>
<body>
</body>
</html>


=================================

"cone_noti.php"



<?php
session_start();
$titulo=$_POST['titulo'];
$fecha=$_POST['fecha'];
$descripcion=$_POST['descripcion'];
$noticia=$_POST['noticia'];
$nameimagen = $_FILES['imagen']['name'];
$tmpimagen = $_FILES['imagen']['tmp_name'];
$extimagen = pathinfo($nameimagen);
$ext = array("png","gif","jpg");
$urlnueva = "imagenes/".$nameimagen;



if(is_uploaded_file($tmpimagen)) {
if(array_search($extimagen['extension'],$ext)){
copy($tmpimagen,$urlnueva);






mysql_connect("localhost","root");
mysql_select_db("prueba1");
mysql_query("INSERT INTO noticias(titulo,fecha,descripcion,noticia,imagen) values('$titulo','$fecha','$descripcion','$noticia ','$urlnueva')");
header("Location:insertarnoti.php");

echo "Se ha guardado correctamente";


} else {
echo "Error: Solo imagenes con formato (jpg, png o gif)";
}
} else {
echo "Elija una imagen";
}

?>





======================================

the resize script to include:




// function to get file extension
function getExtension($str) {

$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
// define max file size, change to suit your own maximum file size
define ("MAX_SIZE","10000");
$errors=0;


//get the original file from form
if($_SERVER["REQUEST_METHOD"] == "POST")
{


// from your upload form

$image = $_FILES["file"]["name"];// from your upload form
$uploadedfile = $_FILES['file']['tmp_name'];// from your upload form
// check for correct file extension
if ($image)
{
$filename = stripslashes($_FILES['file']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{
echo ' Unknown Image extension! ';// build your own error handling here
$errors = 1;
}
// check for correct file size
else
{
$size=filesize($_FILES['file']['tmp_name']);

if ($size > MAX_SIZE*1024)
{
echo "You have exceeded the size limit";// build your own error handling here
$errors = 1;
}
// check which extension we have and create file
if($extension=="jpg" || $extension=="jpeg" )
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
}
else if($extension=="png")
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefrompng($uploadedfile);
}
else
{
$src = imagecreatefromgif($uploadedfile);
}
//resize image and create thumbs and small thumbs
list($width,$height)=getimagesize($uploadedfile);
//for main images, this keeps the width at 300px regardless of portrait or landscape
$newwidth=600;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);
//for thumbnails, change the $newwidth variable to what ever size you need
if($width > $height){//landscape
$newwidth1=200;
$newheight1=($height/$width)*$newwidth1;
$tmp1=imagecreatetruecolor($newwidth1,$newheight1) ;
}elseif($width < $height){//portrait
$newheight1=100;
$newwidth1=($width/$height)*$newheight1;
$tmp1=imagecreatetruecolor($newwidth1,$newheight1) ;
}
//for smaller thumbnails, my site required this smaller thumb. Delete this section if you dont need it
if($width > $height){//landscape
$newwidth2=50;
$newheight2=($height/$width)*$newwidth2;
$tmp2=imagecreatetruecolor($newwidth2,$newheight2) ;
}elseif($width < $height){//portrait
$newheight2=50;
$newwidth2=($width/$height)*$newheight2;
$tmp2=imagecreatetruecolor($newwidth2,$newheight2) ;
}
// create new resized files
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$ne wheight,$width,$height);

imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$ newheight1,$width,$height);

imagecopyresampled($tmp2,$src,0,0,0,0,$newwidth2,$ newheight2,$width,$height);
//declare destinations
$filename = "large/". $_FILES['file']['name'];
$filename1 = "small/". $_FILES['file']['name']; // your destination paths here
$filename2 = "micro/". $_FILES['file']['name'];
//write files to folders
imagejpeg($tmp,$filename,100);
imagejpeg($tmp1,$filename1,100);
imagejpeg($tmp2,$filename2,100);
//destroy temps to save memory
imagedestroy($src);
imagedestroy($tmp);
imagedestroy($tmp1);
imagedestroy($tmp2);
}
}
}

//If no errors registered, insert file name into database and print the success message
if(isset($_POST['invia']) && !$errors)
{
mysql_query("INSERT INTO pictures(name,surname,images) VALUES ('$_POST[name]','$_POST[surname]','src)");



$success = "Image Uploaded Successfully!";
}
////////////////////////

edbr
01-23-2015, 12:55 AM
first check your connection, i see you dont have a password which might throw it out. make a file 1.e conn.php save in your site folder.
add<?php

mysql_connect("localhost", "root" , " ") or die(mysql_error());

?>

then call it in your browser and see if error reported.
it is a better practice to add a user and password to your database anyway as it will be so in a live situation

neodev
01-23-2015, 03:26 AM
Hi edbr,
yes, I have create a "Connection/noticias.php" folder in dreamweaver and I have included it on the page where I show the "insert result, as follow:


(this is the connection script created by dreamweaver:



<?php

error_reporting(E_ALL ^ E_DEPRECATED);

# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_noticias = "localhost";
$database_noticias = "prueba1";
$username_noticias = "root";
$password_noticias = "";
$noticias = mysql_pconnect($hostname_noticias, $username_noticias, $password_noticias) or trigger_error(mysql_error(),E_USER_ERROR);
?>



and this is the "show records page":



<?php require_once('Connections/noticias.php'); ?>

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$maxRows_rs_noticias = 10;
$pageNum_rs_noticias = 0;
if (isset($_GET['pageNum_rs_noticias'])) {
$pageNum_rs_noticias = $_GET['pageNum_rs_noticias'];
}
$startRow_rs_noticias = $pageNum_rs_noticias * $maxRows_rs_noticias;

mysql_select_db($database_noticias, $noticias);
$query_rs_noticias = "SELECT * FROM noticias";
$query_limit_rs_noticias = sprintf("%s LIMIT %d, %d", $query_rs_noticias, $startRow_rs_noticias, $maxRows_rs_noticias);
$rs_noticias = mysql_query($query_limit_rs_noticias, $noticias) or die(mysql_error());
$row_rs_noticias = mysql_fetch_assoc($rs_noticias);

if (isset($_GET['totalRows_rs_noticias'])) {
$totalRows_rs_noticias = $_GET['totalRows_rs_noticias'];
} else {
$all_rs_noticias = mysql_query($query_rs_noticias);
$totalRows_rs_noticias = mysql_num_rows($all_rs_noticias);
}
$totalPages_rs_noticias = ceil($totalRows_rs_noticias/$maxRows_rs_noticias)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>index</title>
</head>
<a href="insertarnoti.php">Insertar noticia</a>
<br />



<body>
<table border="1">
<tr>
<td>titulo</td>
<td>fecha</td>
<td>descripcion</td>
<td>noticia</td>
<td>imagen</td>
</tr>

<?php do { ?>
<tr>
<td><?php echo $row_rs_noticias['titulo']; ?></td>
<td><?php echo $row_rs_noticias['fecha']; ?></td>
<td><?php echo $row_rs_noticias['descripcion']; ?></td>
<td><?php echo $row_rs_noticias['noticia']; ?></td>
<td><img src="<?php echo $row_rs_noticias['imagen']; ?>" width="120px" height="120px" /></td>
</tr>
<?php } while ($row_rs_noticias = mysql_fetch_assoc($rs_noticias)); ?>

</table>
</body>
</html>
<?php
mysql_free_result($rs_noticias);

?>





The connection file is included only in the "show record" page.


As I wrote, all work fine, text field in form pass all the data into database. I miss to insert the script that resize the images into the three folder.

Thanks for support, I hope to see your reply soon.

edbr
01-23-2015, 04:00 AM
im getting confused here,
you said the resize works but no insert into database
now yu say the database works but resizs doesnt??

and mysql_pconnect is depreciated
just use mysql_connect

neodev
01-23-2015, 09:43 AM
I apologize edbr.
You're right. In the last thread I said that resize script doesn't work.
It because I edit and try some combinations and finally the text field work (I mean: go into database). So I need to positioning the resize script (it woks fine, I apologize for mistake), but I was unable to put it inside the form upload (I'm not a developer so...).

Anyway, after days spending time to seach and try to understand how to do that, I reach my goal :wink:
Here I post what I build (please, ceck it anyway) and I have only one question:in the "list page" I'm unable to show the pictures...

I hope it will be useful and help someone out there :-)

The form page:


<?php require_once('Connections/image.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO pic (cognome, nome, img_upload) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['cognome'], "text"),
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString("small/".$_FILES["img_upload"]["name"],"text"));

mysql_select_db($database_image, $image);
$Result1 = mysql_query($insertSQL, $image) or die(mysql_error());

$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: list.php", $insertGoTo));
}

mysql_select_db($database_image, $image);
$query_rs_add = "SELECT * FROM pic";
$rs_add = mysql_query($query_rs_add, $image) or die(mysql_error());
$row_rs_add = mysql_fetch_assoc($rs_add);
$totalRows_rs_add = mysql_num_rows($rs_add);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Create Image Upload with Dreamweaver</title>
</head>

<body>
<?php
include_once("upload.php");
original();
large();
small();
micro();
?>
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1">
<p>
<label><br />
<br />
</label>
<label for="nome"></label>
<label><br />
<br />
</label>
<label for="cognome"></label>
<label><br />
</label>
<input type="hidden" name="MM_insert" value="form1" />
</p>
<table width="366" border="0">
<tr>
<td width="56">Nome</td>
<td width="59">&nbsp;</td>
<td width="218"><input type="text" name="nome" id="nome" /></td>
<td width="15" colspan="2" rowspan="6">&nbsp;</td>
</tr>
<tr>
<td>Cognome</td>
<td>&nbsp;</td>
<td><input type="text" name="cognome" id="cognome" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2">Choose an Image:</td>
<td><input type="file" name="img_upload" id="img_upload" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="btn_upload" id="btn_upload" value="Upload" /></td>
</tr>
</table>
<p>&nbsp;</p>
</form>
</body>
</html>
<?php
mysql_free_result($rs_add);
?>


[PHP]





Here the resize script:

[PHP]



<?php



////////////////// ORIGINAL IMAGE SIZE STORED INTO "ORIGINAL" FOLDER ///////////////////////////

error_reporting(0);
function original(){
if($_FILES["img_upload"]["name"]!=""){
$message = "You must waiting the upload proccess";
if(!copy($_FILES["img_upload"]["tmp_name"],"original/".$_FILES["img_upload"]["name"])){
$message = "Can not upload the Image!!!";
}else{
$message = "The Image was uploaded successfuly...";
echo "<img src='"."original/original_".$_FILES["img_upload"]["name"]."'/>";
}
}else{
$message = "You must select an Image File!!!";
}
if($message != ""){
echo "<div style='background:yellow;color:red;font-size:20px;padding:12px;text-align:center;'>".$message."</div>";
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////// LARGE IMAGE SIZE (600PX WIDE) STORED INTO "LARGE" FOLDER ///////////////////////////

function large(){
if($_FILES["img_upload"]["name"]!=""){
$message = "You must waiting the upload proccess";
$img_file = $_FILES["img_upload"]["tmp_name"];
list($width_ori,$height_ori) = getimagesize($img_file);
$folder = "large/";
if(!is_dir($folder)){
mkdir($folder);
}
$width_new = 600;
$ratio_ori = $width_ori / $height_ori;
$height_new = $width_new / $ratio_ori;
$img_one = imagecreatefromjpeg($img_file);
$img_two = imagecreatetruecolor($width_new,$height_new);
imagecopyresampled($img_two,$img_one,0,0,0,0,$widt h_new,$height_new,$width_ori,$height_ori);
if(imagejpeg($img_two,$folder."/".$_FILES["img_upload"]["name"],100)){
$message = "The File was Uploaded!!!";
echo "<img src='"."large/".$_FILES["img_upload"]["name"]."'/>";
}
}else{
$message = "You must select an Image File!!!";
}
if($message != ""){
echo "<div style='background:yellow;color:red;font-size:20px;padding:12px;text-align:center;'>".$message."</div>";
}
}



//////////////////////////////////////////////////////////////////////////////////////////////////////



////////////////// SMALL IMAGE SIZE STORED INTO "SMALL" FOLDER ///////////////////////////

function small(){
if($_FILES["img_upload"]["name"]!=""){
$message = "You must waiting the upload proccess";
$img_file = $_FILES["img_upload"]["tmp_name"];
list($width_ori,$height_ori) = getimagesize($img_file);
$folder = "small/";
if(!is_dir($folder)){
mkdir($folder);
}
$width_new = 200;
$ratio_ori = $width_ori / $height_ori;
$height_new = $width_new / $ratio_ori;
$img_one = imagecreatefromjpeg($img_file);
$img_two = imagecreatetruecolor($width_new,$height_new);
imagecopyresampled($img_two,$img_one,0,0,0,0,$widt h_new,$height_new,$width_ori,$height_ori);
if(imagejpeg($img_two,$folder."/".$_FILES["img_upload"]["name"],100)){
$message = "The File was Uploaded!!!";
echo "<img src='"."small/".$_FILES["img_upload"]["name"]."'/>";
}
}else{
$message = "You must select an Image File!!!";
}
if($message != ""){
echo "<div style='background:yellow;color:red;font-size:20px;padding:12px;text-align:center;'>".$message."</div>";
}
}



//////////////////////////////////////////////////////////////////////////////////////////////////////





////////////////// MICRO IMAGE SIZE STORED INTO "MICRO" FOLDER ///////////////////////////

function micro(){
if($_FILES["img_upload"]["name"]!=""){
$message = "You must waiting the upload proccess";
$img_file = $_FILES["img_upload"]["tmp_name"];
list($width_ori,$height_ori) = getimagesize($img_file);
$folder = "micro/";
if(!is_dir($folder)){
mkdir($folder);
}
$width_new = 50;
$height_new = 50;
$ratio_width = $width_new / $width_ori;
$ratio_height = $height_new / $height_ori;
if($width_ori > $height_ori){
$width_crop = $width_ori * $ratio_height;
$height_crop = $height_new;
}else if($width_ori < $height_ori){
$width_crop = $width_new;
$height_crop = $height_ori * $ratio_width;
}else{
$width_crop = $width_new;
$height_crop = $height_new;
}
$img_one = imagecreatefromjpeg($img_file);
$img_two = imagecreatetruecolor($width_new,$height_new);
imagecopyresampled($img_two,$img_one,-(($width_crop / 2) - ($width_new / 2)),-(($height_crop / 2) - ($height_new / 2)),0,0,$width_crop,$height_crop,$width_ori,$heigh t_ori);
if(imagejpeg($img_two,$folder."/".$_FILES["img_upload"]["name"],100)){
$message = "The File was Uploaded!!!";
echo "<img src='"."micro/".$_FILES["img_upload"]["name"]."'/>";
}
}else{
$message = "You must select an Image File!!!";
}
if($message != ""){
echo "<div style='background:yellow;color:red;font-size:20px;padding:12px;text-align:center;'>".$message."</div>";
}
}
?>







The add page:





<?php require_once('Connections/image.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$maxRows_rs_list = 5;
$pageNum_rs_list = 0;
if (isset($_GET['pageNum_rs_list'])) {
$pageNum_rs_list = $_GET['pageNum_rs_list'];
}
$startRow_rs_list = $pageNum_rs_list * $maxRows_rs_list;

mysql_select_db($database_image, $image);
$query_rs_list = "SELECT * FROM pic ORDER BY img_upload DESC";
$query_limit_rs_list = sprintf("%s LIMIT %d, %d", $query_rs_list, $startRow_rs_list, $maxRows_rs_list);
$rs_list = mysql_query($query_limit_rs_list, $image) or die(mysql_error());
$row_rs_list = mysql_fetch_assoc($rs_list);

if (isset($_GET['totalRows_rs_list'])) {
$totalRows_rs_list = $_GET['totalRows_rs_list'];
} else {
$all_rs_list = mysql_query($query_rs_list);
$totalRows_rs_list = mysql_num_rows($all_rs_list);
}
$totalPages_rs_list = ceil($totalRows_rs_list/$maxRows_rs_list)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<h1>LIST
</h1>
<p>&nbsp;</p>
<table width="491" border="1">
<tr bgcolor="#66FFFF">
<td>Nome</td>
<td>Cognome</td>
<td>Immagine</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_rs_list['nome']; ?></td>
<td><?php echo $row_rs_list['cognome']; ?></td>
<td><img src="small/<?php echo $row_rs_list['img_upload']; ?>" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<?php } while ($row_rs_list = mysql_fetch_assoc($rs_list)); ?>
</table>
<p><a href="index.php">Add a record</a></p>
</body>
</html>
<?php
mysql_free_result($rs_list);
?>

neodev
01-23-2015, 09:54 AM
Solved the "list.php" page issue (not add.php, sorry :-)):

at this line:

<td><img src="small/<?php echo $row_rs_list['img_upload']; ?>" /></td>

I have just removed the " small/" and all the images appears on this page...

I hope it can help out there...

edbr
01-24-2015, 12:12 AM
no worries , it gets panicky when you struggle to fget it , we a
have all been there. well done for working it out and thanks for posting the solution.

neodev
01-24-2015, 04:43 AM
You're welcome ;-)

neodev
01-26-2015, 06:37 PM
Hi there.
Here again to solve a new problem.
After reach my goal about to load text into db and image (with resize) into 3 different folder and it path into database,I have another question.
I build the edit page (with dreamweaver) .In this page I can edit all the text field plus I can see the actual image into the folders (micro, large and small). I use the same "file field" used in the add.php page and I have attached the "edit.php" file that store the same script that allow me to upload the image into the 3 different folder.When I choose another picture and edit the text fields and press the "update record" button to send the form, I'm redirect to the list page and I see the new photo and the text replaced. So, all is ok! But the problem is that the old images of the previous image still inside the 3 folder. I mean: I need to edit the "edit .php" script to update the old images with the new ones.

After that, I would like to know how I can retrive (for example) an image stored into the large folder and show into a table. In the add form, I've only the file that stored the "small image path".

I hope you can help me. Thanks.

The "edit.php" page:



<?php require_once('Connections/prodotti.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE articoli SET marca=%s, nome=%s, colore=%s, price=%s, descrizione=%s, small=%s, `large`=%s WHERE id=%s",
GetSQLValueString($_POST['marca'], "text"),
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['colore'], "text"),
GetSQLValueString($_POST['price'], "double"),
GetSQLValueString($_POST['descrizione'], "text"),
GetSQLValueString("small/".$_FILES["img_upload"]["name"],"text"),
GetSQLValueString($_POST['large'], "text"),
GetSQLValueString($_POST['id'], "int"));

mysql_select_db($database_prodotti, $prodotti);
$Result1 = mysql_query($updateSQL, $prodotti) or die(mysql_error());

$updateGoTo = "list.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}

$colname_rs_update = "-1";
if (isset($_GET['id'])) {
$colname_rs_update = $_GET['id'];
}
mysql_select_db($database_prodotti, $prodotti);
$query_rs_update = sprintf("SELECT * FROM articoli WHERE id = %s", GetSQLValueString($colname_rs_update, "int"));
$rs_update = mysql_query($query_rs_update, $prodotti) or die(mysql_error());
$row_rs_update = mysql_fetch_assoc($rs_update);
$totalRows_rs_update = mysql_num_rows($rs_update);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
include_once("script/edit.php");
original();
large();
small();
micro();
?>


<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Id:</td>
<td><?php echo $row_rs_update['id']; ?></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Marca:</td>
<td><input type="text" name="marca" value="<?php echo htmlentities($row_rs_update['marca'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Nome:</td>
<td><input type="text" name="nome" value="<?php echo htmlentities($row_rs_update['nome'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Colore:</td>
<td><input type="text" name="colore" value="<?php echo htmlentities($row_rs_update['colore'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Price:</td>
<td><input type="text" name="price" value="<?php echo htmlentities($row_rs_update['price'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Descrizione:</td>
<td><input type="text" name="descrizione" value="<?php echo htmlentities($row_rs_update['descrizione'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Immagine attuale:</td>
<td><img src="<?php echo $row_rs_update['small']; ?>" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Cambia immagine:</td>
<td><label for="img_upload"></label>
<input type="file" name="img_upload" id="img_upload" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Large:</td>
<td><input type="text" name="large" value="<?php echo htmlentities($row_rs_update['large'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Update record" /></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="id" value="<?php echo $row_rs_update['id']; ?>" />
</form>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($rs_update);
?>




The "edit.php" script that load the new image and rewrite on the old one into the three folder with their new size:



<?php


////////////////// ORIGINAL IMAGE SIZE STORED INTO "ORIGINAL" FOLDER ///////////////////////////

error_reporting(0);
function original(){
if($_FILES["img_upload"]["name"]!=""){
$message = "You must waiting the upload proccess";
if(!copy($_FILES["img_upload"]["tmp_name"],"original/".$_FILES["img_upload"]["name"])){
$message = "Can not upload the Image!!!";
}else{
$message = "The Image was uploaded successfuly...";
echo "<img src='"."original/original_".$_FILES["img_upload"]["name"]."'/>";
}
}else{
$message = "You must select an Image File!!!";
}
if($message != ""){
echo "<div style='background:yellow;color:red;font-size:20px;padding:12px;text-align:center;'>".$message."</div>";
}
}



////////////////// LARGE IMAGE SIZE (600PX WIDE) STORED INTO "LARGE" FOLDER ///////////////////////////

function large(){
if($_FILES["img_upload"]["name"]!=""){
$message = "You must waiting the upload proccess";
$img_file = $_FILES["img_upload"]["tmp_name"];
list($width_ori,$height_ori) = getimagesize($img_file);
$folder = "large/";
if(!is_dir($folder)){
mkdir($folder);
}
$width_new = 300;
$ratio_ori = $width_ori / $height_ori;
$height_new = $width_new / $ratio_ori;
$img_one = imagecreatefromjpeg($img_file);
$img_two = imagecreatetruecolor($width_new,$height_new);
imagecopyresampled($img_two,$img_one,0,0,0,0,$widt h_new,$height_new,$width_ori,$height_ori);
if(imagejpeg($img_two,$folder."/".$_FILES["img_upload"]["name"],100)){
$message = "The File was Uploaded!!!";
echo "<img src='"."large/".$_FILES["img_upload"]["name"]."'/>";
}
}else{
$message = "You must select an Image File!!!";
}
if($message != ""){
echo "<div style='background:yellow;color:red;font-size:20px;padding:12px;text-align:center;'>".$message."</div>";
}
}



//////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////// SMALL IMAGE SIZE STORED INTO "SMALL" FOLDER ///////////////////////////

function small(){
if($_FILES["img_upload"]["name"]!=""){
$message = "You must waiting the upload proccess";
$img_file = $_FILES["img_upload"]["tmp_name"];
list($width_ori,$height_ori) = getimagesize($img_file);
$folder = "small/";
if(!is_dir($folder)){
mkdir($folder);
}
$width_new = 100;
$ratio_ori = $width_ori / $height_ori;
$height_new = $width_new / $ratio_ori;
$img_one = imagecreatefromjpeg($img_file);
$img_two = imagecreatetruecolor($width_new,$height_new);
imagecopyresampled($img_two,$img_one,0,0,0,0,$widt h_new,$height_new,$width_ori,$height_ori);
if(imagejpeg($img_two,$folder."/".$_FILES["img_upload"]["name"],100)){
$message = "The File was Uploaded!!!";
echo "<img src='"."small/".$_FILES["img_upload"]["name"]."'/>";
}
}else{
$message = "You must select an Image File!!!";
}
if($message != ""){
echo "<div style='background:yellow;color:red;font-size:20px;padding:5px;text-align:center;'>".$message."</div>";
}
}



//////////////////////////////////////////////////////////////////////////////////////////////////////





////////////////// MICRO IMAGE SIZE STORED INTO "MICRO" FOLDER ///////////////////////////

function micro(){
if($_FILES["img_upload"]["name"]!=""){
$message = "You must waiting the upload proccess";
$img_file = $_FILES["img_upload"]["tmp_name"];
list($width_ori,$height_ori) = getimagesize($img_file);
$folder = "micro/";
if(!is_dir($folder)){
mkdir($folder);
}
$width_new = 50;
$height_new = 50;
$ratio_width = $width_new / $width_ori;
$ratio_height = $height_new / $height_ori;
if($width_ori > $height_ori){
$width_crop = $width_ori * $ratio_height;
$height_crop = $height_new;
}else if($width_ori < $height_ori){
$width_crop = $width_new;
$height_crop = $height_ori * $ratio_width;
}else{
$width_crop = $width_new;
$height_crop = $height_new;
}
$img_one = imagecreatefromjpeg($img_file);
$img_two = imagecreatetruecolor($width_new,$height_new);
imagecopyresampled($img_two,$img_one,-(($width_crop / 2) - ($width_new / 2)),-(($height_crop / 2) - ($height_new / 2)),0,0,$width_crop,$height_crop,$width_ori,$heigh t_ori);
if(imagejpeg($img_two,$folder."/".$_FILES["img_upload"]["name"],100)){
$message = "The File was Uploaded!!!";
echo "<img src='"."micro/".$_FILES["img_upload"]["name"]."'/>";
}
}else{
$message = "You must select an Image File!!!";
}
if($message != ""){
echo "<div style='background:yellow;color:red;font-size:20px;padding:12px;text-align:center;'>".$message."</div>";
}
}
?>

edbr
01-27-2015, 12:11 AM
to delete files you need unlink so ou need to add (suggest before te upload) the unlink code.
example$myFile = "Path to file";// edit the path dynamically
unlink($myFile);

edbr
01-27-2015, 12:13 AM
After that, I would like to know how I can retrive (for example) an image stored into the large folder and show into a table. In the add form, I've only the file that stored the "small image path".

im guessing
<td><img src="large/<?php echo $row_rs_list['img_upload']; ?>" /></td>

neodev
01-27-2015, 12:35 AM
Thanks Edbr, I'll try and let you know....

neodev
01-27-2015, 09:15 AM
Edbr,

I modify your suggest "unlink" code in this way, according to my "edit.php" code:

(your code)
$myFile = "Path to file";// edit the path dynamically
unlink($myFile);

(edit code)


$img_file = ("large/.$img_upload");// edit the path dynamically
unlink($img_file);

$img_file = ("small/.$img_upload");// edit the path dynamically
unlink($img_file);

$img_file = ("micro/.$img_upload");// edit the path dynamically
unlink($img_file);


and I have insert into the edit.php script:



<?php


////////////////// ORIGINAL IMAGE SIZE STORED INTO "ORIGINAL" FOLDER ///////////////////////////

error_reporting(0);
function original(){

$img_file = ("original/.$img_upload");// edit the path dynamically
unlink($img_file);


if($_FILES["img_upload"]["name"]!=""){
$message = "You must waiting the upload proccess";
if(!copy($_FILES["img_upload"]["tmp_name"],"original/".$_FILES["img_upload"]["name"])){
$message = "Can not upload the Image!!!";
}else{
$message = "The Image was uploaded successfuly...";
echo "<img src='"."original/original_".$_FILES["img_upload"]["name"]."'/>";
}
}else{
$message = "You must select an Image File!!!";
}
if($message != ""){
echo "<div style='background:yellow;color:red;font-size:20px;padding:12px;text-align:center;'>".$message."</div>";
}
}



////////////////// LARGE IMAGE SIZE (600PX WIDE) STORED INTO "LARGE" FOLDER ///////////////////////////

function large(){



$img_file = ("large/.$img_upload");// edit the path dynamically
unlink($img_file);

if($_FILES["img_upload"]["name"]!=""){


$message = "You must waiting the upload proccess";
$img_file = $_FILES["img_upload"]["tmp_name"];
list($width_ori,$height_ori) = getimagesize($img_file);
$folder = "large/";
if(!is_dir($folder)){
mkdir($folder);
}
$width_new = 300;
$ratio_ori = $width_ori / $height_ori;
$height_new = $width_new / $ratio_ori;
$img_one = imagecreatefromjpeg($img_file);
$img_two = imagecreatetruecolor($width_new,$height_new);
imagecopyresampled($img_two,$img_one,0,0,0,0,$widt h_new,$height_new,$width_ori,$height_ori);



if(imagejpeg($img_two,$folder."/".$_FILES["img_upload"]["name"],100)){
$message = "The File was Uploaded!!!";
echo "<img src='"."large/".$_FILES["img_upload"]["name"]."'/>";
}



}else{
$message = "You must select an Image File!!!";
}
if($message != ""){
echo "<div style='background:yellow;color:red;font-size:20px;padding:12px;text-align:center;'>".$message."</div>";
}
}



//////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////// SMALL IMAGE SIZE STORED INTO "SMALL" FOLDER ///////////////////////////

function small(){

$img_file = ("small/.$img_upload");// edit the path dynamically
unlink($img_file);

if($_FILES["img_upload"]["name"]!=""){


$message = "You must waiting the upload proccess";
$img_file = $_FILES["img_upload"]["tmp_name"];
list($width_ori,$height_ori) = getimagesize($img_file);
$folder = "small/";
if(!is_dir($folder)){
mkdir($folder);
}
$width_new = 100;
$ratio_ori = $width_ori / $height_ori;
$height_new = $width_new / $ratio_ori;
$img_one = imagecreatefromjpeg($img_file);
$img_two = imagecreatetruecolor($width_new,$height_new);
imagecopyresampled($img_two,$img_one,0,0,0,0,$widt h_new,$height_new,$width_ori,$height_ori);



if(imagejpeg($img_two,$folder."/".$_FILES["img_upload"]["name"],100)){
$message = "The File was Uploaded!!!";
echo "<img src='"."small/".$_FILES["img_upload"]["name"]."'/>";
}


}else{
$message = "You must select an Image File!!!";
}
if($message != ""){
echo "<div style='background:yellow;color:red;font-size:20px;padding:5px;text-align:center;'>".$message."</div>";
}
}



//////////////////////////////////////////////////////////////////////////////////////////////////////





////////////////// MICRO IMAGE SIZE STORED INTO "MICRO" FOLDER ///////////////////////////

function micro(){


$img_file = ("micro/.$img_upload");// edit the path dynamically
unlink($img_file);

if($_FILES["img_upload"]["name"]!=""){





$message = "You must waiting the upload proccess";
$img_file = $_FILES["img_upload"]["tmp_name"];
list($width_ori,$height_ori) = getimagesize($img_file);
$folder = "micro/";
if(!is_dir($folder)){
mkdir($folder);
}
$width_new = 50;
$height_new = 50;
$ratio_width = $width_new / $width_ori;
$ratio_height = $height_new / $height_ori;
if($width_ori > $height_ori){
$width_crop = $width_ori * $ratio_height;
$height_crop = $height_new;
}else if($width_ori < $height_ori){
$width_crop = $width_new;
$height_crop = $height_ori * $ratio_width;
}else{
$width_crop = $width_new;
$height_crop = $height_new;
}
$img_one = imagecreatefromjpeg($img_file);
$img_two = imagecreatetruecolor($width_new,$height_new);
imagecopyresampled($img_two,$img_one,-(($width_crop / 2) - ($width_new / 2)),-(($height_crop / 2) - ($height_new / 2)),0,0,$width_crop,$height_crop,$width_ori,$heigh t_ori);
if(imagejpeg($img_two,$folder."/".$_FILES["img_upload"]["name"],100)){
$message = "The File was Uploaded!!!";
echo "<img src='"."micro/".$_FILES["img_upload"]["name"]."'/>";
}




}else{
$message = "You must select an Image File!!!";
}
if($message != ""){
echo "<div style='background:yellow;color:red;font-size:20px;padding:12px;text-align:center;'>".$message."</div>";
}
}
?>




I positioning the 3 new code several times and position in the script, but nothing..please, can you let me see where I must put it?
Thanks

neodev
01-27-2015, 04:21 PM
Hi EDBR,
I have tried to reason about your answer. You wrote me to insert the "unlink" to delete the old images files inside the 3 folder (large, small and micro). So I have:

$myFile = "Path to file";// edit the path dynamically
unlink($myFile);


that I have translate in this way:


$myFile = "large/".$_FILES["img_upload"]["name"];// edit the path dynamically
$myFile = "small/".$_FILES["img_upload"]["name"];// edit the path dynamically
$myFile = "micro/".$_FILES["img_upload"]["name"];// edit the path dynamically
unlink($myFile);




I have insert this code not into "edit.php" where is located the script that resize image, but into the "edit.php" generated by dreamweaver (where is located the upload form), just before the upload script, as you told me:





if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}





$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}







if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {



//////////////////////////////////////////THE UNLINK CODE //////////////////////////
$myFile = "large/".$_FILES["img_upload"]["name"];// edit the path dynamically
$myFile = "small/".$_FILES["img_upload"]["name"];// edit the path dynamically
$myFile = "micro/".$_FILES["img_upload"]["name"];// edit the path dynamically
unlink($myFile);
//////////////////////////////////////////////////////////////////////////////////////////


$updateSQL = sprintf("UPDATE articoli SET marca=%s, nome=%s, colore=%s, price=%s, descrizione=%s, small=%s, `large`=%s WHERE id=%s",
GetSQLValueString($_POST['marca'], "text"),
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['colore'], "text"),
GetSQLValueString($_POST['price'], "double"),
GetSQLValueString($_POST['descrizione'], "text"),
GetSQLValueString("small/".$_FILES["img_upload"]["name"],"text"),
GetSQLValueString($_POST['large'], "text"),
GetSQLValueString($_POST['id'], "int"));







mysql_select_db($database_prodotti, $prodotti);
$Result1 = mysql_query($updateSQL, $prodotti) or die(mysql_error());

$updateGoTo = "list.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}

$colname_rs_update = "-1";
if (isset($_GET['id'])) {
$colname_rs_update = $_GET['id'];
}
mysql_select_db($database_prodotti, $prodotti);
$query_rs_update = sprintf("SELECT * FROM articoli WHERE id = %s", GetSQLValueString($colname_rs_update, "int"));
$rs_update = mysql_query($query_rs_update, $prodotti) or die(mysql_error());
$row_rs_update = mysql_fetch_assoc($rs_update);
$totalRows_rs_update = mysql_num_rows($rs_update);





But I still not reach my goal.
Plus, I have insert the code to retrive the image from "large" folder into a html row, as you wrote me:


<td><img src="large/<?php echo $row_rs_list['img_upload']; ?>" /></td>


but it doesn't work. Where I mistake?

Thanks for support

edbr
01-28-2015, 12:06 AM
first i think that might be the wrong path
$myFile = "large/".$_FILES["img_upload"]["name"];

2 if you are unlinking multiple files you will need to put them into an array

3 clearly a path issue
<td><img src="large/<?php echo $row_rs_list['img_upload']; ?>"</td> />

neodev
01-28-2015, 05:25 PM
I think this is the "path/image": "small/".$_FILES["img_upload"]["name"];

I try to position the code several times in the edit .php. The image was replaced, but the old one still there.

edbr
01-29-2015, 12:08 AM
i will have to replicate this script but today at least i wont have time. ill let you know

post here a zip with your relevant pages and add a database file so i can follow your db structure. you can export in phpadmin includesreat

neodev
01-29-2015, 12:27 PM
I have included a zip file called "db". You will find the sql file with the table (to import into mysql).
The "edit.php" file that contain the form and the code generated by Dreamweaver,
inside the "script" folder you'll find the "edit.php" that resize the images
on upload.



I really appreciate it. I'm getting mad about it. Thank you.

edbr
01-30-2015, 12:21 AM
ok i will try to look over the weekend

neodev
01-30-2015, 08:51 AM
Thank you edbr

edbr
02-02-2015, 04:33 AM
ok i looked at your files and here is why its not doing what you want.
you are uploading images using original names. so you have to retrieve that existing name in order to delete it as a new file has different name. below is a simple upload that will put resized images into your folder names, it renames as image .jpg into a folder named original, resizes then deletes the original upload. try it and see call it whatever and make a folder called original. this is ok as an update inmage if you pass the existing image name to the script before you start.

here are some problems though, you do not filter file types so a possible security flaw where someone could up load a malicious file .
will the user only be allowed image? if so you need to name the files accordingly. or at least structure yoursite differently.

any way here is the example file with comments that i hope will help you

ction=" " method="post" enctype="multipart/form-data" id="something" class="uniForm">
<input name="new_image" id="new_image" size="30" type="file" class="fileUpload" />
<button name="submit" type="submit" class="submitButton">Upload Image</button>
</form>
<?php

$newfilename = "image.jpg"; //can name dynamically



if(isset($_POST['submit'])){
if (isset ($_FILES['new_image'])){
$imagename = $_FILES['new_image']['name'];

$imagename = $newfilename;
$source = $_FILES['new_image']['tmp_name'];
$target = "original/".$imagename;
move_uploaded_file($source, $target);





$imagepath = $imagename;
$save = "large/" . $imagepath; //This is the new file you saving
$file = "original/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = 500;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 500) ;


$save = "small/" . $imagepath; //This is the new file you saving
$file = "original/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = 180;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;

$save = "micro/" . $imagepath; //This is the new file you saving
$file = "original/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = 80;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save,100) ;


unlink($save );// deletes existing file
imagejpeg($tn, $save, 100) ;

unlink($file );// deletes original file

echo "Large image: <img src='large/".$imagepath."'><br>";
echo "Small image: <img src='small/".$imagepath."'><br>";
echo "Thumbnail: <img src='micro/".$imagepath."'>";

}
}
?>

neodev
02-03-2015, 09:30 AM
Thanks a lot, I'll try and let you know...

neodev
02-03-2015, 12:46 PM
Edbr,
thanks for your support.
The script you send me work nice. Finally, if you go to edit page and change the image, The new image will upload into the three folder and the old one disapper. Great job.

But the new image take name like this: "image.jpg". This because, into your script, you rename the new image upload:



$newfilename = "image.jpg"; //can name dynamically
........




This make different issue. First of all, I can't see the old image into the "edit page" before uploading the new one, and into database, in the small field (that hold the "path/imagename.jpg") appear the original name of teh file, not "image.jpg".
Same thing at the list page: no pic appear.
At the end, i belive that the problem is how to overwrite the new image name on the old one. So I think to edit the first php code line.
How I can do this?

Thanks

edbr
02-04-2015, 01:21 AM
yes i was just showing the error you need to pass the record (probably as $_get) and rewrite the script to update the record.

neodev
02-04-2015, 09:49 PM
Hi edbr,
well, I try to change some line of code, but I can't show the image just uploaded/update :-(

edbr
02-05-2015, 12:28 AM
then its not updating the image name

neodev
02-05-2015, 07:22 AM
Hi edbr,
as I said, your script work fine. I mean: the image is update, the new one owerwrite the old one, but the new "name" make different issue.
The first one is that the database hold the original name of the file, not the new one (image.jpg), then the same image is not more visible into the list page and into the edit page.

The goal is keep the same name of the file while is updating.

I try to study and change this code that you wrote me:

==============================================
$newfilename = "image.jpg"; //can name dynamically



if(isset($_POST['submit'])){
if (isset ($_FILES['new_image'])){
$imagename = $_FILES['new_image']['name'];

$imagename = $newfilename;
$source = $_FILES['new_image']['tmp_name'];
$target = "original/".$imagename;
move_uploaded_file($source, $target);


==============================================


But after several try, only error are displayed.
I don't know what to do.

edbr
02-06-2015, 12:25 AM
i thought i did . you have to rewrite an update script

edbr
02-06-2015, 03:28 AM
get the record for updating and identify the image previously in the database and use unlink, then yu vcan use a any name you like including original name.
something like

$delete=$row['file']; //image path in database
unlink("../large/$delete");
unlink("../small/$delete");

neodev
02-06-2015, 06:25 PM
Hi edbr,

I have just put this lines of code at the top of the "upload.php" script, and if I choose a new image with the sane name of the old one, the script replace the old one! But I'm understanding that I need to hold the "id" of the product, so I need that every new image file (with any name) will replace the old one. Please, help me because this script let being me insane, thanks.

[PHP]

////////////////// ORIGINAL IMAGE SIZE STORED INTO "ORIGINAL" FOLDER ///////////////////////////

error_reporting(0);




//////////////I have added this 2 line to check if the file exists and unlink. It seem work
nice cause replace the images into the three folder, but only if
the new image has the same name like the old one image ////////////////////

$myFile = ($_FILES['img_upload']['name']); //image path in database;
unlink($myFile);





function original(){





if($_FILES["img_upload"]["name"]!=""){
$message = "You must waiting the upload proccess";
if(!copy($_FILES["img_upload"]["tmp_name"],"original/".$_FILES["img_upload"]["name"])){
$message = "Can not upload the Image!!!";
}else{
$message = "The Image was uploaded successfuly...";
echo "<img src='"."original/original_".$_FILES["img_upload"]["name"]."'/>";
}
}else{

[PHP]

edbr
02-07-2015, 11:51 PM
then I would think you should be naming the image dynamically( as i suggested) with the product id. that should cure all your ills

neodev
02-08-2015, 08:26 AM
Ok, thanks..but how to do that? Where I must put the new code? Into the dreamweaver phhp code or into the "resize" script? I search by google, try several times but nothing...

edbr
02-09-2015, 05:12 AM
the simplest way could be to insert record in two stages first info then add image and use the uniquw id or that record as an image
name

neodev
02-09-2015, 05:11 PM
After searching for several times, I found some code by example and I build up what I'm looking for. Now, the update form really upload the image , overwriting the existing one. It seem perfect. But now, I need to integrate the resize script that I include in the previous step. As usual, I try several times to include it, but the insert form and edit don't work more. This is the last step: all I need is to insert the resize code in the "insert.php" page to load the image and resizing it into 3 different size into 3 different folder, same thing in the edit page.

Please, could you tell me where I must put in? Thanks.


The "insert.php" page:
//////////////////////////////////////////////////////////////////////////


<?php

error_reporting(0);
include_once("conn/DB.php");





if (isset($_POST['save']))
{
if(($_FILES['file']['type'] =='image/gif')
|| ($_FILES['file']['type'] =='image/jpeg')
|| ($_FILES['file']['type'] =='image/pjpeg')
&& ($_FILES['file']['size'] < 200000))


{
if ($_FILES['file']['error'] > 0)
{
echo "return code:" . $_FILES['file']['error'];
}
else if(file_exists('upload/'.$_FILES['file']['name']))
{
echo $_FILES['file']['name']."Already Exit";
}
else if(move_uploaded_file($_FILES['file']['tmp_name'],
'upload/'.$_FILES['file']['name']))
{



$part = $_FILES['file']['name'];
$sql = mysql_query("INSERT INTO tblstudent
(studentname,surname,address,photo)
VALUES('{$_POST['studentname']}',
'{$_POST['surname']}',
'{$_POST['address']}',
'{$part}')");
if ($sql)
{
echo "successfully insert this record.....";
}
else
{
echo "error insert";
}
}

}

header('Location: list.php');
}

///////////////////////// End code insert image to database /////////////////////////
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>


<?php
include_once("resize.php");
original();
large();
small();
micro();
?>



<form id="form1" name="form1" method="post" action="insert.php" enctype="multipart/form-data">
<table width="503" border="1" align="center">
<tr>
<td colspan="3" align="center"><h2>Student Information</h2></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="115" bgcolor="#66FFFF">Student Name:</td>
<td width="372" colspan="2"><label for="studentname"></label>
<input name="studentname" type="text" id="studentname" size="50" /></td>
</tr>
<tr>
<td bgcolor="#66FFFF"><p>Surname:</p></td>
<td colspan="2"><label for="surname"></label>
<input name="surname" type="text" id="surname" size="50" /></td>
</tr>
<tr>
<td bgcolor="#66FFFF">Address:</td>
<td colspan="2"><label for="address"></label>
<input name="address" type="text" id="address" size="50" /></td>
</tr>
<tr>
<td height="26">Foto</td>
<td colspan="2"><label for="file"></label>
<input name="file" type="file" id="file" size="38" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2"><input type="submit" name="save" id="button" value="save" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</table>
</form>

</body>
</html>







The "resize.php" script
///////////////////////////////////////////////////////////////////////////////////


<?php

include_once("conn/DB.php");

////////////////// ORIGINAL IMAGE SIZE STORED INTO "ORIGINAL" FOLDER ///////////////////////////

error_reporting(0);




////////////////// LARGE IMAGE SIZE (600PX WIDE) STORED INTO "LARGE" FOLDER ///////////////////////////

function large(){


if($_FILES["file"]["name"]!=""){
$message = "You must waiting the upload proccess";
$img_file = $_FILES["file"]["tmp_name"];
list($width_ori,$height_ori) = getimagesize($img_file);
$folder = "large/";
if(!is_dir($folder)){
mkdir($folder);
}
$width_new = 300;
$ratio_ori = $width_ori / $height_ori;
$height_new = $width_new / $ratio_ori;
$img_one = imagecreatefromjpeg($img_file);
$img_two = imagecreatetruecolor($width_new,$height_new);
imagecopyresampled($img_two,$img_one,0,0,0,0,$widt h_new,$height_new,$width_ori,$height_ori);
if(imagejpeg($img_two,$folder."/".$_FILES["file"]["name"],100)){
$message = "The File was Uploaded!!!";
echo "<img src='"."".$_FILES["file"]["name"]."'/>";
}
}else{
$message = "You must select an Image File!!!";
}
if($message != ""){
echo "<div style='background:yellow;color:red;font-size:20px;padding:12px;text-align:center;'>".$message."</div>";
}
}



//////////////////////////////////////////////////////////////////////////////////////////////////////



////////////////// SMALL IMAGE SIZE STORED INTO "SMALL" FOLDER ///////////////////////////

function small(){



if($_FILES["file"]["name"]!=""){
$message = "You must waiting the upload proccess";
$img_file = $_FILES["file"]["tmp_name"];
list($width_ori,$height_ori) = getimagesize($img_file);
$folder = "small/";
if(!is_dir($folder)){
mkdir($folder);
}
$width_new = 100;
$ratio_ori = $width_ori / $height_ori;
$height_new = $width_new / $ratio_ori;
$img_one = imagecreatefromjpeg($img_file);
$img_two = imagecreatetruecolor($width_new,$height_new);
imagecopyresampled($img_two,$img_one,0,0,0,0,$widt h_new,$height_new,$width_ori,$height_ori);
if(imagejpeg($img_two,$folder."/".$_FILES["file"]["name"],100)){
$message = "The File was Uploaded!!!";
echo "<img src='"."".$_FILES["file"]["name"]."'/>";
}
}else{
$message = "You must select an Image File!!!";
}
if($message != ""){
echo "<div style='background:yellow;color:red;font-size:20px;padding:5px;text-align:center;'>".$message."</div>";
}
}



//////////////////////////////////////////////////////////////////////////////////////////////////////





////////////////// MICRO IMAGE SIZE STORED INTO "MICRO" FOLDER ///////////////////////////

function micro(){

if($_FILES["file"]["name"]!=""){
$message = "You must waiting the upload proccess";
$img_file = $_FILES["file"]["tmp_name"];
list($width_ori,$height_ori) = getimagesize($img_file);
$folder = "micro/";
if(!is_dir($folder)){
mkdir($folder);
}
$width_new = 50;
$height_new = 50;
$ratio_width = $width_new / $width_ori;
$ratio_height = $height_new / $height_ori;
if($width_ori > $height_ori){
$width_crop = $width_ori * $ratio_height;
$height_crop = $height_new;
}else if($width_ori < $height_ori){
$width_crop = $width_new;
$height_crop = $height_ori * $ratio_width;
}else{
$width_crop = $width_new;
$height_crop = $height_new;
}
$img_one = imagecreatefromjpeg($img_file);
$img_two = imagecreatetruecolor($width_new,$height_new);
imagecopyresampled($img_two,$img_one,-(($width_crop / 2) - ($width_new / 2)),-(($height_crop / 2) - ($height_new / 2)),0,0,$width_crop,$height_crop,$width_ori,$heigh t_ori);
if(imagejpeg($img_two,$folder."/".$_FILES["file"]["name"],100)){
$message = "The File was Uploaded!!!";
echo "<img src='"."".$_FILES["file"]["name"]."'/>";
}
}else{
$message = "You must select an Image File!!!";
}
if($message != ""){
echo "<div style='background:yellow;color:red;font-size:20px;padding:12px;text-align:center;'>".$message."</div>";
}
}



?>






The "edit.php" page
//////////////////////////////////////////////////////////////////////////////



<?php

include_once("conn/DB.php");





$id = $_GET['ide'];
if(isset($_GET['ide']))
{
$sql = mysql_query("SELECT * FROM tblstudent WHERE id = '{$id}'");
$row = mysql_fetch_object($sql);
$picture = $row->photo;

}


if (isset($_POST['save']))
{
$newpicture = $_FILES['file']['name'];
if ($newpicture)
{
if(($_FILES['file']['type'] =='image/gif')
|| ($_FILES['file']['type'] =='image/jpeg')
|| ($_FILES['file']['type'] =='image/pjpeg')
&& ($_FILES['file']['size'] <200000))
{
if ($_FILES['file']['error'] > 0)
{
echo "returncode:" . $_FILES['file']['error'];
}
else if(file_exists('upload/'.$_FILES['file']['name']))
{
echo $_FILES['file']['name']."Already Exit";
}
else if (move_uploaded_file($_FILES['file']['tmp_name'],
'upload/'.$_FILES['file']['name']))

{
unlink('upload/'.$picture);
$sqledit = "UPDATE tblstudent
SET
studentname = '{$_POST['studentname']}',
surname = '{$_POST['surname']}',
address = '{$_POST['address']}',
photo = '$newpicture'
WHERE id = '{$id}'";
$re = mysql_query($sqledit);
if ($re)
{
header('location:list.php');
}
}
}

}
else
{
$sqlphoto = "UPDATE tblstudent
SET
studentname = '{$_POST['studentname']}',
surname = '{$_POST['surname']}',
address = '{$_POST['address']}'
WHERE id = '{$id}'";
$res = mysql_query($sqlphoto);
if ($res)
{
header('location:list.php');
}
}
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>


<form id="form1" name="form1" method="post" action="" enctype="multipart/form-data">

<table width="503" border="1" align="center">
<input type="hidden" value="<?php echo $row->id; ?>"/>
<tr>
<td colspan="3" align="center"><h2>Edit Student Information</h2></td>
</tr>

<tr>
<td height="76" colspan="3" align="center"><a href="list.php">Lista prodotti</a></td>
</tr>
<tr>
<td width="115" bgcolor="#66FFFF">Student Name:</td>
<td width="372" colspan="2"><label for="studentname"></label>
<input name="studentname" type="text" id="studentname" size="50" value="<?php echo $row->studentname; ?>" /></td>
</tr>
<tr>
<td bgcolor="#66FFFF"><p>Surname:</p></td>
<td colspan="2"><label for="surname"></label>
<input name="surname" type="text" id="surname" size="50" value="<?php echo $row->surname; ?>"/></td>
</tr>
<tr>
<td bgcolor="#66FFFF">Address:</td>
<td colspan="2"><label for="address"></label>
<input name="address" type="text" id="address" size="50" value="<?php echo $row->address; ?>"/></td>
</tr>
<tr>

<td><img src="<?php echo 'upload/'.$picture ?>" style="width:100px; height:100px;" /></td>
<td colspan="2"><label for="file"></label>
<input name="file" type="file" id="file" size="38" /></td>

</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2"><input type="submit" name="save" id="button" value="Update" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</table>

</form>


</body>
</html>




Thanks for your patience and time.