hello..
How to upload image file in page update ..??
i have logic like this :
if user upload new image then old image must delete and update DB used new name
if user not upload new image then old image no delete.
code form like this (i dontknow this code right or wrong, please correction if wrong) :
[CODE]
<?php
// make a note of the current working directory relative to root.
$directory_self = str_replace(bas ename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);
// make a note of the location of the upload handler
$uploadHandler = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'codetesupdok1. php';
// set a max file size for the html upload form
$max_file_size = 50000; // size in bytes
?>
<html>
<body>
<form method="post" action="proces. php" enctype="multip art/form-data">
<?php
$contact = $_POST["contact"];
foreach ( $contact as $value )
{
$sqla = "SELECT * FROM `$table` WHERE `int_prop_ID` ='$value'";
$resulta = mysql_query($sq la) or die (mysql_error ());
if ($myrowa = mysql_fetch_arr ay($resulta))
{
do {
$ida = $myrowa["int_prop_I D"];
$resultx = "SELECT * FROM `$table` WHERE int_prop_ID = '$ida' ";
$resultb = mysql_query($re sultx) or die (mysql_error ());
$myrowb = mysql_fetch_arr ay($resultb);
$price = $myrowa["int_price"];
$image1 = $myrowa["str_image1 "];
<table>
<tr>
<td><b><font size=2 face=tahoma>Pri ce :</b></font></td>
</tr>
</table>
<input size="8" type="text" name="updprice[]" value="<?php echo $price ?>">
<br><br>
<table>
<tr>
<td><b><font size=2 face=tahoma>Ima ge :</b></font></td>
</tr>
</table>
<input type="text" name="updimage1[]" value="<?php echo $image1 ?>">
<input type="hidden" name="MAX_FILE_ SIZE" value="<?php echo $max_file_size ?>">
<input id="file" type="file" name="file[]">
<?php
} while ($myrowa = mysql_fetch_arr ay($resulta));
}
} ?>
<div align="center">
<hr>
<input type="submit" value="Save">
</div>
</form>
my confused : how process to upload image in page update, i want if user upload new image then old image must delete?
NB : in page insert data, Im saving image file to folder
// Create folder
$folder = "../property/$property_id";
mkdir($folder);
please help ..??
thanks
How to upload image file in page update ..??
i have logic like this :
if user upload new image then old image must delete and update DB used new name
if user not upload new image then old image no delete.
code form like this (i dontknow this code right or wrong, please correction if wrong) :
[CODE]
<?php
// make a note of the current working directory relative to root.
$directory_self = str_replace(bas ename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);
// make a note of the location of the upload handler
$uploadHandler = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'codetesupdok1. php';
// set a max file size for the html upload form
$max_file_size = 50000; // size in bytes
?>
<html>
<body>
<form method="post" action="proces. php" enctype="multip art/form-data">
<?php
$contact = $_POST["contact"];
foreach ( $contact as $value )
{
$sqla = "SELECT * FROM `$table` WHERE `int_prop_ID` ='$value'";
$resulta = mysql_query($sq la) or die (mysql_error ());
if ($myrowa = mysql_fetch_arr ay($resulta))
{
do {
$ida = $myrowa["int_prop_I D"];
$resultx = "SELECT * FROM `$table` WHERE int_prop_ID = '$ida' ";
$resultb = mysql_query($re sultx) or die (mysql_error ());
$myrowb = mysql_fetch_arr ay($resultb);
$price = $myrowa["int_price"];
$image1 = $myrowa["str_image1 "];
<table>
<tr>
<td><b><font size=2 face=tahoma>Pri ce :</b></font></td>
</tr>
</table>
<input size="8" type="text" name="updprice[]" value="<?php echo $price ?>">
<br><br>
<table>
<tr>
<td><b><font size=2 face=tahoma>Ima ge :</b></font></td>
</tr>
</table>
<input type="text" name="updimage1[]" value="<?php echo $image1 ?>">
<input type="hidden" name="MAX_FILE_ SIZE" value="<?php echo $max_file_size ?>">
<input id="file" type="file" name="file[]">
<?php
} while ($myrowa = mysql_fetch_arr ay($resulta));
}
} ?>
<div align="center">
<hr>
<input type="submit" value="Save">
</div>
</form>
my confused : how process to upload image in page update, i want if user upload new image then old image must delete?
NB : in page insert data, Im saving image file to folder
// Create folder
$folder = "../property/$property_id";
mkdir($folder);
please help ..??
thanks