aris1234 Posted June 11, 2007 Share Posted June 11, 2007 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) : <?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 Quote Link to comment https://forums.phpfreaks.com/topic/55053-how-to-upload-image-file-in-update-page/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.