tags:

views:

60

answers:

2

y0 c0derz!

My formula looks like this:

<form method="post" action="index.php?sida=upl" enctype="multipart/form-data" name="myform">

        <input type="file" name="picture" id="picture" class="file_1" />
        <input type="image" name="submit" style="margin-left: 120px;" src="uplbutt.png" />

</form>

And the PHP code for the formula looks like this:

if (array_key_exists('image', $_POST)) 
{
// do something here bla bla
}

But when i click on the image-submit button nothing happens as it is suppose to happen? What could be wrong?

+1  A: 

Image inputs are sent as (x, y) coordinates, like [name].x and [name].y.

Since these aren't valid PHP variable names, the points are replaced by underscores, so you need to look for:

if (array_key_exists('image_x', $_POST))
Greg
Great dude! That did it!
A: 

The key in the $_POST superglobal will not be the "type" attribute of the input of the form, but it's "name" attribute -- or something based on its name, depending on the input's type (for an image input, there should be image_x and image_y, if I remember correctly).


To get a dump of what is POSTed, you can use, for instance :

var_dump($_POST);

This will show you which variables you can use on the PHP side.

Pascal MARTIN