Warptweet Posted March 20, 2007 Share Posted March 20, 2007 Here is my code for my uploader... if ($_GET['cmd'] == 'submit'){ if ($_GET['step'] == 'two'){ echo "<form enctype=\"multipart/form-data\" action=\"?cmd=submit&step=three\" method=\"POST\"> Upload this File: <input name=\"file\" type=\"file\" size=\"20\" /> <font size=\"2\" color=\"#FF0000\">*<b>Maximum</b> 50 Megabytes.</font><br /> Creation's Name/Title: <input type=\"text\" name=\"creationname\" size=\"20\"> <font size=\"2\" color=\"#FF0000\"> *<b>Maximum</b> 50 characters.</font><br> Creations Description: <input type=\"text\" name=\"creationdescription\" size=\"20\"> <font size=\"2\" color=\"#FF0000\">*<b>Maximum</b> 250 characters.</font><br> Link to Icon: <input type=\"text\" name=\"iconlink\" size=\"20\"> <font size=\"2\" color=\"#FF0000\">*Optional. <b>50x50 pixels</b> if possible.</font><br> <input type=\"submit\" value=\"Continue to Step 3\" />"; } } if ($_GET['cmd'] == 'submit'){ if ($_GET['step'] == 'three'){ function generate_rand($l){ $c= "WARPTWEETwarptweet179SCscONon"; srand((double)microtime()*1000000); for($i=0; $i<$l; $i++) { $rand.= $c[rand()%strlen($c)]; } return $rand; } $uploaddir = "pending/"; $maxfilesize = 104857600; //1 megabyte $filename = $_FILES['file']['name']; $filesize = $_FILES['file']['size']; $filetmpname = $_FILES['file']['tmp_name']; $valid = array (".gm6",".zip",".gmk",".gmd",".tar"); if ($filename) { $error = ""; if ($filesize == 0) { $error .= "The file is invalid.<br />"; } $type = strtolower(strstr($filename, '.')); if (!in_array($type, $valid)) { $error .= "The submitted file may only be a .gm6, .gmd, .gmk, .gm5, or a .exe file.<br />"; } if ($filesize>$maxfilesize) { $error .= "The submitted file may not be larger than 50 Megabytes.<br />"; } if (!$_POST['creationname']){ $error .= "You did not enter a name for your Creation!<br />"; } if (!$_POST['creationdescription']){ $error .= "You did not enter a description for your Creation!<br />"; } $randnum = generate_rand(10); $randnum .= $type; $file_exists = true; while ($file_exists) { if (file_exists("$uploaddir$randnum")) { $randnum = generate_rand(10); $randnum .= $type; }else{ $file_exists = false; } } Now, everything works right, it looks right. although, if I try uploading a .gm6 file, it will give me the "Only .gm6, .gmk, .gm5, .gmd, .exe, and .exe files are allowed" error for some reason, even though it IS a .gm6 file! If I upload a .exe file, or a .zip file, it says "The file is invalid" error. Whats wrong? Why is it so bad at file verification? Link to comment https://forums.phpfreaks.com/topic/43547-uploader-not-verifying-correctly/ Share on other sites More sharing options...
Warptweet Posted March 20, 2007 Author Share Posted March 20, 2007 Anyone? I still need help pelase Link to comment https://forums.phpfreaks.com/topic/43547-uploader-not-verifying-correctly/#findComment-211636 Share on other sites More sharing options...
suzzane2020 Posted March 20, 2007 Share Posted March 20, 2007 I think u cud use it this way if(($_FILES['file']['type'])!=("ext")) { echo "invalid filetype"; } Link to comment https://forums.phpfreaks.com/topic/43547-uploader-not-verifying-correctly/#findComment-211643 Share on other sites More sharing options...
Warptweet Posted March 21, 2007 Author Share Posted March 21, 2007 That doesn't work Okay, after a few very minor changes in the code, here is my ENTIRE uploader code. It has to do int he general error area, where the errors are displayed. I keep getting the error whom "Your submission could not be uploaded" when I try uploading a .zip file, but a .gmk file works for some reason. if ($_GET['cmd'] == 'submit'){ if ($_GET['step'] == 'one'){ echo "Thank you for visiting the Submission page!</br>Before we begin with the Content Submission, I would like to clarify with you that you completely agree with everything that our Terms of Service (ToS) state, and that they may be changed at any time, and still have 100% effect upon you. </br></br><b>By going to the next step of Content Submission, you agree to the above.</b></br></br><b>Click <a href=\"?cmd=submit&step=two\">here</a> to continue to step two."; } } if ($_GET['cmd'] == 'submit'){ if ($_GET['step'] == 'two'){ echo "<form enctype=\"multipart/form-data\" action=\"?cmd=submit&step=three\" method=\"POST\"> Upload this File: <input name=\"file\" type=\"file\" size=\"20\" /> <font size=\"2\" color=\"#FF0000\">*<b>Maximum</b> 50 Megabytes.</font><br /> Creation's Name/Title: <input type=\"text\" name=\"creationname\" size=\"20\"> <font size=\"2\" color=\"#FF0000\"> *<b>Maximum</b> 50 characters.</font><br> Creations Description: <input type=\"text\" name=\"creationdescription\" size=\"20\"> <font size=\"2\" color=\"#FF0000\">*<b>Maximum</b> 250 characters.</font><br> Link to Icon: <input type=\"text\" name=\"iconlink\" size=\"20\"> <font size=\"2\" color=\"#FF0000\">*Optional. <b>50x50 pixels</b> if possible.</font><br> <input type=\"submit\" value=\"Continue to Step 3\" />"; } } if ($_GET['cmd'] == 'submit'){ if ($_GET['step'] == 'three'){ function generate_rand($l){ $c= "WARPTEONwarpteon179"; srand((double)microtime()*1000000); for($i=0; $i<$l; $i++) { $rand.= $c[rand()%strlen($c)]; } return $rand; } $uploaddir = "flashuploads/"; $maxfilesize = 41943040; //40 megabytes $filename = $_FILES['file']['name']; $filesize = $_FILES['file']['size']; $filetmpname = $_FILES['file']['tmp_name']; $valid = array (".gm6",".gm5",".gmd",".zip"); if ($filename) { $error = ""; $type = strtolower(strstr($filename, '.')); if (!in_array($type, $valid)) { $error .= "The submitted file was of invalid type. Only .gmk, .gmk6, and .zip files are allowed. If you have a .exe file, please compress it into a .zip file.<br />"; } if ($filesize>$maxfilesize) { $error .= "The submitted file was larger than 100 Megabytes..<br />"; } $randnum = generate_rand(10); $randnum .= $type; $file_exists = true; while ($file_exists) { if (file_exists("$uploaddir$randnum")) { $randnum = generate_rand(10); $randnum .= $type; }else{ $file_exists = false; } } if ($error == "") { if (move_uploaded_file($filetmpname, "$uploaddir$randnum")) { chmod("$uploaddir$randnum", 0644); $creationname = $_POST['creationname']; $creationdescription = $_POST['creationdescription']; echo "Thank you! Please finish the last step to complete the upload!</br></br> <form enctype=\"multipart/form-data\" action=\"?cmd=submit&step=four\" method=\"POST\"> Select which suits your Creation best: <select size=\"1\" name=\"uploadtype\"> <option selected>Playable/Game</option> <option>Program/Tool</option> </select> <input type='hidden' name='creationname' value='$creationname'> <input type='hidden' name='creationdescription' value='$creationdescription'> <input type='hidden' name='iconlink' value='$iconlink'> <input type='hidden' name='uploadlink' value='$uploaddir'> <input type='hidden' name='uploadrand' value='$randnum'> <br> Select which genre suits your Creation best: <select size=\"1\" name=\"uploadgenre\"> <option selected>Role Playing Game</option> <option>Classical Game</option> <option>Fan Game</option> <option>Arcade Game</option> <option>Multiple Minigames</option> <option>Minigame</option> <option>Puzzle Game</option> <option>Sports Game</option> <option>Computer Tool</option> <option>Real Time Strategy</option> <option>Online Multiplayer</option> <option>Adventure Game</option> <option>Mystery Game</option> <option>Action Game</option> <option>Other Genre</option> <option>First Person Shooter</option> </select><br> Select which idea suits your Creation best: <select size=\"1\" name=\"uploadstyle\"> <option>Platform</option> <option>Mech</option> <option>Futuristic Gameplay</option> <option>Computer Help</option> <option>Drawing Program</option> <option>Computer Program</option> <option>Advanced Computering</option> <option>Classic BoardGame</option> <option>Classic Wormz</option> <option>Classical Game</option> <option>Classical Collection</option> <option>Watching Simulation</option> <option>Massively Multiplayer</option> <option>Simply Online</option> <option>Team Online</option> <option>Online Roleplaying</option> <option>FanGame</option> <option>Metroid FanGame</option> <option>Halo FanGame</option> <option>3D Shooter</option> <option>3D Simulation</option> <option>3D Action</option> <option>3D Game</option> <option>Pick and Watch</option> <option>God Power</option> <option>Vehicular Game</option> <option>Vehicular Combat</option> <option>Racing Game</option> <option>Interative Show</option> <option>Maze Game</option> <option>Vertical Scrolling Shooter</option> <option>Horizontal Scrolling Shooter</option> <option>Vertical Scrolling</option> <option>Horizontal Scrolling</option> <option>Traditional</option> <option>Time Waster</option> <option>Artillery</option> <option>Educational</option> <option>Soccer</option> <option>Football</option> <option>Baseball</option> <option>Running</option> <option>Cross Country</option> <option>Music Based</option> <option>Party Games</option> <option>Mario FanGame</option> <option>Zelda FanGame</option> <option>Kirby FanGame</option> <option>Stealth Tactics</option> <option>Text Adventure</option> <option>Pixel Style</option> <option>Strategy WarGame</option> <option>Turn-Based</option> <option>Real-Time Tactical</option> <option>Logical Solution Finding</option> <option>Hack n Slash</option> <option>Beat em Up</option> <option>Competitive Fighting</option> <option>Simulations</option> <option>Economic Simulation</option> <option>Government Simulation</option> <option>City Building</option> </select><br> <input type=\"submit\" value=\"Continue to Step 4\" /> "; } else { echo "Sorry, your submitted file could not be uploaded!"; } }else{ echo $error; } }else{ echo "No file was uploaded!"; } } } Link to comment https://forums.phpfreaks.com/topic/43547-uploader-not-verifying-correctly/#findComment-211753 Share on other sites More sharing options...
Warptweet Posted March 21, 2007 Author Share Posted March 21, 2007 I still need help, please! This should be working, please help! Link to comment https://forums.phpfreaks.com/topic/43547-uploader-not-verifying-correctly/#findComment-212120 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.