Search code examples
phpfilemamp

I am not able to retrieve file name after submission


if($_SERVER['REQUEST_METHOD'] == 'POST') {
        $image = $_FILES["image"]["name"];

        echo "File: " . $image;
    }

the echo is "File :" all the time

        <form action="" method="post" id="formAddProperty">
            <div id="propertyImage">
                <label for="image">Upload image:</label>
                <input type="file" name="image">
            </div>

            <input type="submit" value="Add Property" id="propertySubmit">
        </form>

I'm running a local server via mamp, is than an issue? The purpose is to get file name than its extension (which is not shown in this example).


Solution

  • You are missing

    enctype="multipart/form-data"
    

    in the form

    <form action="" method="post" id="formAddProperty" enctype="multipart/form-data">