[Solved] $_FILES[“file”][“name”] is returning empty value [closed]


In your case the problem is the following line:

header('Location: '.$redirect);

When you first run move_uploaded_file and then make redirection using header function, $_FILES array gets empty, so in next line simple you cannot check $_FILES anymore.

In addition I don’t see any point making this redirectrion. When you move_uploaded_file it simple return true on success so you could change the following code:

<?php 
if ($_POST)
    {
        $folder = "box/"; 
        $redirect = "index.php?complete";

        move_uploaded_file($_FILES["file"]["tmp_name"], "$folder" . $_FILES["file"]["name"]);

        header('Location: '.$redirect);
    }

if (isset($_GET['complete'])) 

into

<?php 

$uploadStatus = false;
if ($_POST)
    {
        $folder = "box/"; 

       $uploadStatus = move_uploaded_file($_FILES["file"]["tmp_name"], "$folder" . $_FILES["file"]["name"]);

    }

if ($uploadStatus) 

1

solved $_FILES[“file”][“name”] is returning empty value [closed]