ayok Posted July 31, 2007 Share Posted July 31, 2007 Hi, Now I'm trying to create a form to a database which contain image. So besides submitting some data, it also upload an image to a folder. But everytime I upload the image, the script acknowledge it as a non image file. Here are part my codes: upload_form.php: <?php <tr><td>Upload Image:</td> <td> <input type=file name=fupload></td></tr></table> <INPUT TYPE=SUBMIT VALUE=Go> </FORM> input image.php <?php $direktori_file = "products/pics/$fupload_name"; if($fupload_type != "image/gif" AND $fupload_type != "image/jpeg" AND$fupload_type != "image/pjpeg" AND $fupload_type != "image/png"){ echo "The type of file <b>$fupload_name</b> is $fupload_type<br>"; echo "The file must be image file<br>"; echo "<a href=add.php>Upload again!</a>"; } elseif (!move_uploaded_file($fupload, "$direktori_file")){ echo "The upload is failed!"; } everytime I submit the pic, i've got this kind of message: The type of file pic01.gif is image/gif The file must be image file Upload again! Why the script doesn't recognize my gif/jpeg files? FYI, I still test this on localhost. thanks, ayok Link to comment https://forums.phpfreaks.com/topic/62706-upload-image-question/ Share on other sites More sharing options...
Wildbug Posted July 31, 2007 Share Posted July 31, 2007 Change your ANDs to or's. Link to comment https://forums.phpfreaks.com/topic/62706-upload-image-question/#findComment-312137 Share on other sites More sharing options...
ayok Posted July 31, 2007 Author Share Posted July 31, 2007 Hey thanks wildbug, but i got the same result. ayok Link to comment https://forums.phpfreaks.com/topic/62706-upload-image-question/#findComment-312149 Share on other sites More sharing options...
Wildbug Posted July 31, 2007 Share Posted July 31, 2007 Post your form code. Link to comment https://forums.phpfreaks.com/topic/62706-upload-image-question/#findComment-312156 Share on other sites More sharing options...
ayok Posted July 31, 2007 Author Share Posted July 31, 2007 Strange.. I changed the AND's into OR's as you adviced, but it didn't affect, so I changed back to AND's. Now I've got different result. It's my form.php, btw: <FORM><tr><td>Content:</td> <td><INPUT NAME=Content type=text size=10 maxlength="2"></td></tr> <tr><td>Price:</td> <td>EUR <input NAME=Price type=text size=10 maxlength="10"> (please use .00 as decimal)</td></tr> <tr><td>Upload Image:</td> <td> <input type=file name=fupload></td></tr></table> <INPUT TYPE=SUBMIT VALUE=Go> </FORM> Link to comment https://forums.phpfreaks.com/topic/62706-upload-image-question/#findComment-312161 Share on other sites More sharing options...
redarrow Posted July 31, 2007 Share Posted July 31, 2007 form correct format <!-- The data encoding type, enctype, MUST be specified as below --> <form enctype="multipart/form-data" action="__URL__" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> <!-- Name of input element determines name in $_FILES array --> Send this file: <input name="userfile" type="file" /> <input type="submit" value="Send File" /> </form> Link to comment https://forums.phpfreaks.com/topic/62706-upload-image-question/#findComment-312165 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.