php - Getting the image file into the file field while updating record
if(isset($_GET['edit']))
{
$Id=$_GET['edit'];
//Get Form Data from Data base against the Id
$Edit_Query="SELECT * FROM products WHERE id='$Id'";
$Result=mysql_query($Edit_Query);
while($Row=mysql_fetch_array($Result))
{
$Id=$Row['id'];
$Product_Name=$Row['product_name'];
$Product_Price=$Row['price'];
$Product_Details=$Row['details'];
$Category=$Row['category'];
$Subcategory=$Row['subcategory'];
$File_Name=$Row['product_picture'];
}
Now I echoed all variable into my input fields...
Please note that['product_picture']
is the file name only ... physical file is uploaded in to my uploads folder...
Now i want to get that physical file automatically into my file field...so if user just change other fields and hit update button ... it will update the rest of the record and file should be remained as it is in the folder as well as db with that particular$ID
.
I tried<input type="file" name="product_picture" value="<php echo $File_Name; ?>">
but it is not even echoing the file name....
In simple words its like User want to update the record but its not necessary that he must have to update the file too.... it should be on choice ..
Answer
Solution:
Try this,
Use a hidden field to store the image ID in,
Then you can use it to assign the new image the previous ID and not have to update the SQL database.