Page 1 of 1

Help with Image posting with form to database with php

Posted: Fri Jul 15, 2005 2:59 am
by Alleg
Hello !
Im newbie to php . I want to post some data with form and Image or binary date i use the following code:
<form action="/CMS/Img.php" method="post" enctype="multipart/form-data" name="form1">
<INPUT type ="text" name="txtName" id="txtName">
<INPUT type ="image" src="../media/10.gif" name = "Img">
<INPUT name=Submit type=submit value=Submit>
<input name="Reset" type="reset" value="Reset">
</form>
the php Code:
$txtName = Trim($_POST["txtName"]) ;
$Img = $_POST["Img"] ;
$Query= "insert into product (Name ,Picture )
values ('$txtName','$Img')" ;
why i cant get the Img field from form
Can you help
Thanks very much

Posted: Fri Jul 15, 2005 3:18 am
by onion2k
Image input elements return name.x and name.y, which PHP translates into $_POST['name_x'] and $_POST['name_y']. They contain the coordinates of where the user clicked.

http://www.zend.com/manual/faq.html.php ... form-image

If the user clicks the submit button in your example instead of the image then there won't be anything returned for img. Likewise, if the user clicks the image, nothing will be returned for the submit button.