By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,041 Members | 1,279 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,041 IT Pros & Developers. It's quick & easy.

Help : How to upload image file in update page

P: 9

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) :


// make a note of the current working directory relative to root.
$directory_self = str_replace(basename($_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


<form method="post" action="proces.php" enctype="multipart/form-data">
$contact = $_POST["contact"];
foreach ( $contact as $value )
$sqla = "SELECT * FROM `$table` WHERE `int_prop_ID` ='$value'";
$resulta = mysql_query($sqla) or die (mysql_error ());

if ($myrowa = mysql_fetch_array($resulta))
do {
$ida = $myrowa["int_prop_ID"];

$resultx = "SELECT * FROM `$table` WHERE int_prop_ID = '$ida' ";
$resultb = mysql_query($resultx) or die (mysql_error ());
$myrowb = mysql_fetch_array($resultb);

$price = $myrowa["int_price"];
$image1 = $myrowa["str_image1"];

<td><b><font size=2 face=tahoma>Price :</b></font></td>
<input size="8" type="text" name="updprice[]" value="<?php echo $price ?>">

<td><b><font size=2 face=tahoma>Image :</b></font></td>
<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[]">

} while ($myrowa = mysql_fetch_array($resulta));
} ?>

<div align="center">
<input type="submit" value="Save">

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";

please help ..??
Jun 11 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.