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

Help : How to upload image file in update page

P: 9
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(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
?>

<html>
<body>

<form method="post" action="proces.php" enctype="multipart/form-data">
<?php
$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"];


<table>
<tr>
<td><b><font size=2 face=tahoma>Price :</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>Image :</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_array($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
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.