pluginbaby Posted November 25, 2006 Share Posted November 25, 2006 [code]<?phpif (($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg")&& ($_FILES["file"]["size"] < 64000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } }}else { echo "Invalid file";}?>[/code]here is my test code to upload a file, later it needs more working out :)But I got basic, and when I tested, I succesfully uploaded a .gif file (whoohoow), but when I tried a .jpg or a .jpeg, it displayed "Invalid file". How can this be helped (better: can this be helped? :) ) Link to comment https://forums.phpfreaks.com/topic/28432-upload-image-help/ Share on other sites More sharing options...
glenelkins Posted November 25, 2006 Share Posted November 25, 2006 perhaps try puttin Xor in place of || between the test for "image/jpeg" and "image/jpg" ?? Link to comment https://forums.phpfreaks.com/topic/28432-upload-image-help/#findComment-130125 Share on other sites More sharing options...
pluginbaby Posted November 25, 2006 Author Share Posted November 25, 2006 thanks for the helpbut it was no use, it didn't work. I also tried them all alone with the others (aka: gif without jpg and jpeg; jpeg without gif and jpg ... ) And still only gif works. I think it is weird, anyone any suggestions? ;D Link to comment https://forums.phpfreaks.com/topic/28432-upload-image-help/#findComment-130147 Share on other sites More sharing options...
mansuang Posted November 25, 2006 Share Posted November 25, 2006 You can check file type on the top of your script.<?php[color=red]print_r($_FILES["file"]["type"]) ;exit;[/color]if (($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg")&& ($_FILES["file"]["size"] < 64000)) {...........................You can see file type such as: "image/pjpeg"Then remove [color=red]print_r($_FILES["file"]["type"]) ;exit;[/color]and put type of file that you see in your script ('if' statement).Hope it helps Link to comment https://forums.phpfreaks.com/topic/28432-upload-image-help/#findComment-130149 Share on other sites More sharing options...
pluginbaby Posted November 25, 2006 Author Share Posted November 25, 2006 thanks for the helpI works perfect now. Your solution of printing it was so simple, stupid not to think of it haha ;D ;Danyway, nice job helping megreettzzI love you PHP Freaks Link to comment https://forums.phpfreaks.com/topic/28432-upload-image-help/#findComment-130166 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.