This doesn’t appear to have anything to do with Laravel. Also, don’t link to your code – include it in the question itself by putting a line with three backticks ``` before and after each code block.
Dec 20, 2022
8
Level 1
Only Text Insert in Database. Image not insert in database.
Issue was in PHP
When i fill the form only text field is update on database image file not updated on database.
database table name : datesheet
datesheet table column name : coursename , sheet
After fill form only data was fill on coursename. sheet show blank but i add image on form. it's also not uploaded on path that i define where the image file are stored.
HTML FORM FOR UPLOAD :
<form action="action/Add-Datesheet.php>" method="post" enctype="multipart/form-data">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-11">
<div class="form-group">
<label for="">Course Full Name</label>
<input type="text" class="form-control" name="coursename" required>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-11">
<div class="form-group">
<label for="">Upload Datsheet</label>
<input type="file" class="form-control" name="sheet" required>
</div>
</div>
</div>
<div class="form-group">
<input type="submit" value="Upload Datesheet" name='image'>
</div>
</form>
Form Action Code
<?php
session_start();
include('../../config.php');
$coursename = $_POST['coursename'];
$sheet = $_POST['sheet'];
$file_tmp = $_FILES["sheet"]["tmp_name"];
$img_path = "images/UserImage/";
$imagename = $img_path . $file_name;
$Insert_Sql = "INSERT INTO datesheet (sheet, coursename) VALUES('$sheet', '$coursename')";
$result = mysqli_query($conn, $Insert_Sql);
if($result){
move_uploaded_file($file_tmp, "/images/UserImage/". $file_name);
echo "
<script>
alert('Datesheet Added');
window.location.href='../View-Blogs.php';
</script>
";
}else{
echo "
<script>
alert(Some Error Found. Please Try Again Later.);
</script>
";
}
?>
Please or to participate in this conversation.