Вопрос

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).

Это было полезно?

Решение

You are missing

enctype="multipart/form-data"

in the form

<form action="" method="post" id="formAddProperty" enctype="multipart/form-data">
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top