Hi ,
In a form , I have a field for image , in edit page, i can display that image, when I am clicking update, without modifying image it shows error in image.
How to save previous image if its not changed.
Sample Code:
<span><img src="profile/<?=$rows["upload"]; ?>" id="blah" style="height:25%; width:50%;"><br />
<input type="file" name="upload" id="upload" onChange="validation();putImage();" style="margin-top:10%;" tabindex="12"/>
</span>
Update page:
<?php
include('connect.php');
$random_no=rand(10000000,99999999);
$filename = $_FILES['upload']['tmp_name'];
//echo $filename;
//exit;
if(!empty($filename))
{
$file_size = $_FILES['upload']['size'];
if($file_size> 1048576)
{
echo "<script type='text/javascript'>alert('File Size Exceed 1 Mb!'); window.location.href='preview.php';</script>";
}
else
{
$target_path = "profile/";
$uploaded_files=$random_no."_".$_FILES['upload']['name'];
move_uploaded_file($_FILES['upload']['tmp_name'], $target_path .$random_no."_".$_FILES['upload']['name']);
}
}
$newupid=mysql_query("update candidate setupload='$uploaded_files' where id='$upid'")or die(mysql_error());
echo "<script type='text/javascript'> alert('Updated Successfully'); window.location.href='otpreview.php';</script>";
?>