Tomcat 6 & PHP with enctype - No input data returned

216 Views Asked by At

I have this problem when I'm using PHP5/HTML on Apache-Tomcat6. Here's an example for one of the forms I use in my site:

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


    <label>Title* :</label> 
    <input type="text" name="title" /> 




    <label>Image:</label>
    <input type="file" name="image" /><br />



<input type="submit" value="Add"/>
</form>

Whenever I add the 'enctype' attribute to any form; neither the $_FILES['image'] is returned nor the $_POST variables. As long as the 'enctype' is not there, everything (except for the file input of course) works as expected. Can any one guide me please?

1

There are 1 best solutions below

8
On

You won't be able to post data with a method of get on your form.

In test.html:

<form enctype="multipart/form-data" method="post" action="hello.php" >
    <label>Title* :</label> 
    <input type="text" name="title" /> 

    <label>Image:</label>
    <input type="file" name="image" /><br />
    <input type="submit" value="Add"/>
</form>

In hello.php:

<?php
print_r($_POST);
print_r($_FILES);

Depending upon your server configuration, this will combine $_GET, $_POST, and $_COOKIE, but you'll still want to post with file inputs.

print_r($_REQUEST);