Home > database >  Why does PHP not GET the form input from this HTML form?
Why does PHP not GET the form input from this HTML form?

Time:09-27

<form method="post" enctype="multipart/form-data" name="formUploadFile">      
<label>Select files to upload:</label>
<input type="file" name="files[]" multiple="multiple" /><br>
IF you didn't add tags in the image titles your can add them here "," seperated eg tagone,tagtwo,tagthree,tagfour <br> 
<input type="text" name="Tags"><br>
<input type="submit" value="Upload File" name="btnSubmit"/>
</form>

<?php

$tags =  $_GET["Tags"];

    foreach($_FILES["files"]["tmp_name"] as $key=>$tmp_name){
    $temp = $_FILES["files"]["tmp_name"][$key];
    $name = $_FILES["files"]["name"][$key];

    if(empty($temp))
    {
            break;
    }

CodePudding user response:

The $_GET superglobal is populated by data from the query string of the URL.

A form, with method="POST", will put data from the form controls in the request body, not the query string. (Data in the query string of the action will still be there).

You need to read it from $_POST (except for files which are in $_FILES).

CodePudding user response:

I think you are able to try in below.

$tags = $_POST["Tags"];

  • Related