I am building a upload page that will allow me to upload the picture and the record will be stored in MySQL. For now, I am able to save the record. However, I am having the problem in storing the picture in my actual file and the picture is not storing.
The code is below:
<?php
include "config.php";
if (isset($_FILES['file'])) {
$name = $_FILES['file']['name'];
$size = $_FILES['file']['size'];
$type = $_FILES['file']['type'];
$tmp = $_FILES['file']['tmp_name'];
$file = 'uploads'. $_FILES['file']['name'];
$upload = move_uploaded_file($tmp, $file);
if ($upload) {
$add = $db->prepare("insert into upload values('',?)");
$add->bindParam(1, $name);
if ($add->execute()) {
?>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success!</strong> File upload successful to database.
</div>
<?php
} else {
?>
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Failed!</strong> File upload unsuccessful to database.
</div>
<?php
}
} else {
?>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Sorry!</strong> File upload unsuccessful .
</div>
<?php
}
}
?>


'uploads'. $_FILES['file']['name'];?<form>for this along with the input for the file. There could be something in there that isn't right.$file = 'uploads'. $_FILES['file']['name'];'interprets to and for example:uploadsIMAGE.jpgrather thanuploads/IMAGE.jpgusing$file = 'uploads/'. $_FILES['file']['name'];- also make sure the path is correct and that the folder has proper permissions to write to it.