nimirraj99 Posted April 30, 2007 Share Posted April 30, 2007 i'm new at this and i can't figure out why it isn't working. this is my PHP script <html> <body> <?php if (($_FILES["picture"]["type"] == "image/gif") || ($_FILES["picture"]["type"] == "image/pjpeg") && ($_FILES["picture"]["size"] < 20000)) { if ($_FILES["picture"]["error"] > 0) { echo "Return Code: " . $_FILES["picture"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["picture"]["name"] . "<br />"; echo "Type: " . $_FILES["picture"]["type"] . "<br />"; echo "Size: " . ($_FILES["picture"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["picture"]["tmp_name"] . "<br />"; echo $_POST ["picture"] if (file_exists("upload/" . $_FILES["picture"]["name"])) { echo $_FILES["picture"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["picture"]["tmp_name"], "upload/" . $_FILES["picture"]["name"]); echo "Stored in: " . "upload/" . $_FILES["picture"]["name"]; } } } else { echo "ERROR! Invalid file"; } ?> </body> </html> and this is what it should have done * Saves the uploaded image into a specific directory. * Prints a confirmation message back to the user showing all the information received (date, time, title, etc) as well as information about the image file (type, size, name) * Your confirmation page should include the image itself (the actual picture, I mean). * Your confirmation page should also contain the "Back" button that brings to the input form. * In a case of failure you should print an error message. * Before moving the uploaded file from its temp location make sure that its size doesn't exceed 2 MB. If it does display an appropriate error message. can someone help? Link to comment https://forums.phpfreaks.com/topic/49251-somethings-wrong/ Share on other sites More sharing options...
tauchai83 Posted April 30, 2007 Share Posted April 30, 2007 double post is against rules!!! you using 2 username here? don't you? Your code is same with the the code you post before with DIFFERENT user name. What tactic is that? :-\ Link to comment https://forums.phpfreaks.com/topic/49251-somethings-wrong/#findComment-241309 Share on other sites More sharing options...
skali Posted April 30, 2007 Share Posted April 30, 2007 One issue that i see clearly is that you are not using "()" to join you "||" operators with your "&&" operator. Meaning according to your code file type must be image/pjpeg and its size must be < 2 mb only then this code will work, which you surely do not want. You also want image/gif files to be regarded by your code. Try if ( ( ($_FILES["picture"]["type"] == "image/gif") || ($_FILES["picture"]["type"] == "image/pjpeg") ) && ($_FILES["picture"]["size"] < 20000) ) Link to comment https://forums.phpfreaks.com/topic/49251-somethings-wrong/#findComment-241310 Share on other sites More sharing options...
nimirraj99 Posted April 30, 2007 Author Share Posted April 30, 2007 i'm sorry i don't understand what you mean? do mean me or the code? me, i just got here and have only posted twice. my code, it is something i am working on for a class project so it is possible you have seen something similar. i just don't know what i'm doing really and just wondered if anyone could tell me what i might be doing wrong. honestly i'm pretty much lost on this stuff ??? Link to comment https://forums.phpfreaks.com/topic/49251-somethings-wrong/#findComment-241313 Share on other sites More sharing options...
tauchai83 Posted April 30, 2007 Share Posted April 30, 2007 just reply honestly: nimirraj99==oceans? Link to comment https://forums.phpfreaks.com/topic/49251-somethings-wrong/#findComment-241320 Share on other sites More sharing options...
nimirraj99 Posted April 30, 2007 Author Share Posted April 30, 2007 just reply honestly: nimirraj99==oceans? i see now why you say that. but we aren't the same person. like i said i don't know what i'm doing really so i've been looking at numerous tutorials and code sites for help. apparently this person was using the same one i was. and apparently they have no clue what they are doing either. honestly though i'm not the other person. i'm just nimirraj99. and thanks to skali for the positive feedback! Link to comment https://forums.phpfreaks.com/topic/49251-somethings-wrong/#findComment-241324 Share on other sites More sharing options...
tauchai83 Posted April 30, 2007 Share Posted April 30, 2007 ok. that's fine. Moderator can check it out. It was so "accidently" your title came after the oceans one. And almost same code. anyway, happy posting. Link to comment https://forums.phpfreaks.com/topic/49251-somethings-wrong/#findComment-241328 Share on other sites More sharing options...
nimirraj99 Posted April 30, 2007 Author Share Posted April 30, 2007 yeah i realize thats kinda weird and thanks Link to comment https://forums.phpfreaks.com/topic/49251-somethings-wrong/#findComment-241330 Share on other sites More sharing options...
nimirraj99 Posted April 30, 2007 Author Share Posted April 30, 2007 One issue that i see clearly is that you are not using "()" to join you "||" operators with your "&&" operator. Meaning according to your code file type must be image/pjpeg and its size must be < 2 mb only then this code will work, which you surely do not want. You also want image/gif files to be regarded by your code. Try if ( ( ($_FILES["picture"]["type"] == "image/gif") || ($_FILES["picture"]["type"] == "image/pjpeg") ) && ($_FILES["picture"]["size"] < 20000) ) okay so if i'm thinking correctly if i do it like this if ( ( ($_FILES["picture"]["type"] == "image/gif" || $_FILES["picture"]["type"] == "image/jpeg") ) && ($_FILES["picture"]["size"] < 20000) ) ...this will give me a check on file type "image/gif" or "image/jpeg" and a file size where they both (type and size) have to be returned true, is that right? (sorry if this seems silly but i really am having that much trouble)??? Link to comment https://forums.phpfreaks.com/topic/49251-somethings-wrong/#findComment-241331 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.