Home » Php » php – move_uploaded_file() function does not work (

php – move_uploaded_file() function does not work (

Posted by: admin February 25, 2020 Leave a comment

Questions:

I build a image upload system to db and I want to move the image to upload folder when I upload image by move_uploaded_file and that’s don’t work.

if(isset($_POST['project_save'])) {
$title = $_POST['wTitle'];
$description = $_POST['wDescription'];
$link = $_POST['wLink'];
$image = $_FILES["wImage"]["name"];
$target = "../admin/upload/".basename($_FILES['wImage']['name']);

$query = "INSERT INTO portfolio (title, description, link, image) VALUES ('$title', '$description', '$link', '$image')";
$query_run = mysqli_query($connection, $query);

if(move_uploaded_file($_FILES['wImage']['name'], $target)) {
    $_SESSION['success'] = "Image Not Upload !";
    header("Location: portfolio.php");
} else {
    $_SESSION['success'] = "Image Upload !";
    header("Location: portfolio.php");
}

}

I tried the var $target in all variation:
upload/ admin/upload/ ../admin/upload/
and nothing work.
thanks !

How to&Answers: