473,394 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Help : How to upload image file in update page

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
0 1964

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

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
3
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
0
by: SEMIH DEMIR | last post by:
Sitelerden birinde verilen yabancı kaynakli bir scriptti duzenledim yanlız birseyin içinden bir turlu cıkamadım işin aslı ilk defa persistin upload componentini kullanacam yanlız suanki haliyle...
4
by: Jim Michaels | last post by:
after a file upload, $_FILES is not populated but $_POST is. what's going on here? $_POST=C $_POST=C $_POST=C $_POST=C:\\www\\jimm\\images\\bg1.jpg $_FILES= $_FILES= $_FILES=
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
3
by: Milagro | last post by:
Hello Everyone, I'm trying to debug someone elses php code. I'm actually a Perl programmer, with OO experience, but not in php. The code is supposed to upload a photo from a form and save it...
7
by: dragiton | last post by:
SA Upload SQL Database variable types (image upload and storage) I am having trouble with the SA Upload utility. The following code used to work correctly. However, I lost my database and had to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.