1
I have a web application, where everything is running smoothly with exception of file upload.
the PHP responsible for storing the data in the database and saving the file in the folder is this
<?php
session_start();
include_once("connect.php");
$fname = filter_input(INPUT_POST, 'fname', FILTER_SANITIZE_STRING);
$lname = filter_input(INPUT_POST, 'lname', FILTER_SANITIZE_STRING);
$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_email);
$file = $_FILE['file']['name'];
$result_file = "INSERT INTO work (fname, lname,email, file) VALUES (:fname, :lname,:email, :file)";
$insert_msg = $con->prepare($result_file);
$insert_msg -> bindParam(':fname',$fname);
$insert_msg -> bindParam(':lname',$lname);
$insert_msg -> bindParam(':email',$email);
$insert_msg -> bindParam(':file',$file);
if($insert_msg->execut()){
$last_id = $con->lasInsertId();
$folder = 'files/' .$last_id '/';
mkdir($folder,0755);
move_uploaded_file($_FILES['file']['tmp_name']$folder.$file);
$_SESSION['msg'] = "<p style='color:gren;'> File sent successfully</p>";
header("Location: index.php");
}else{
$_SESSION['msg'] = "<p style='color:red;'>Failed to send file</p>";
header("Location: index.php")
}
But he’s not saving any information or saving the file.
In
if($insert_msg->execut())
, shouldn’t beif($insert_msg->execute())
? No exception is appearing?– Marcus Italo