How to edit & update image file in php
꧁ Digital Diary ༒Largest Writing Community༒꧂
꧁ Digital Diary ༒Largest Writing Community༒꧂
<?php
include("Connection.php");
?>
<!-- select--->
<?php
$quer="SELECT * FROM `image` WHERE id='".$_GET['id']."'";
$ru=mysqli_query($connection,$quer);
$fetch=mysqli_fetch_assoc($ru)
?>
<!--update-->
<?php
if(isset($_POST['sub']))
{
$name=$_POST['name'];
$file=$_FILES["img"]["name"];
if ($file=="") {
$run=mysqli_query($connection,"UPDATE `image` SET name='$name' WHERE id='".$_GET['id']."'");
if ($run) {
echo "ok";
}
else{
echo "no";
}
}
else{
$tempimage=$_FILES["img"]["tmp_name"];
$move=move_uploaded_file($tempimage,"image/".$file);
$run=mysqli_query($connection,"UPDATE `image` SET name='$name', image='$file' WHERE id='".$_GET['id']."'");
if ($run) {
echo "ok";
}
else{
echo "no";
}
}
}
?>
<table align="center" border="2px">
<form method="POST" accept="" enctype="multipart/form-data">
<tr>
<th>Name</th>
<td><input type="text" name="name" value="<?php echo $fetch['name'];?>"></td>
</tr>
<tr>
<th>Image</th>
<td><img src="image/<?php echo $fetch['image'];?>"width="100px"; height="100px";> <br>
<input type="file" name="img">
</td>
</tr>
<tr><th colspan="2"><input type="submit" name="sub" value="Insert"></th></tr>
</form>
</table>
</body>
</html>
We are accepting Guest Posting on our website for all categories.
I want to Hire a Professional..
Ashish ranjan
@DigitalDiaryWefru