简体   繁体   中英

Why I am not getting the POST data of image?

My index.html file:

    <form action="upload.php" method="post">
    Title: <input type="text" name="title" required="required"></br>
    Filename: <input type="file" name="file"><br>
    <input type="submit" name="upload" class="submit" value="Upload">
    </form>

And upload.php:

 if (isset($_POST["upload"])){ upload(); } 

Well, I have a function that uploads and there is no problem, in that function I think. Help me plzz

Its because the form does not encrypt your file. Just use this:

 <form action="upload.php" method="post" enctype="multipart/form-data">

instead of

 <form action="upload.php" method="post">

in the 1st line of form

You have to add enctype= "multipart/form-data" to send files through form

<form action="upload.php" method="post" enctype= "multipart/form-data">

enctype='multipart/form-data' is an encoding type that allows files to be sent through a POST. Quite simply, without this encoding the files cannot be sent through POST.

For file uploading in form you have to add enctype= "multipart/form-data" in form. It sends form-data encoded as "multipart/form-data".

<form action="upload.php" method="post" enctype= "multipart/form-data">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM