KingOfHeart Posted October 30, 2009 Share Posted October 30, 2009 I want to read the data from an uploaded file. Not sure why, but it only uploads for certain files. Not sure if it has to do with the size or what. Even when I comment all of the if and else statements, and comment out the reading statement it still acts like the file has not been uploaded. Here's the data from a file that does not work. (6.25kb) 300 0 0 o_brick * 0 32 o_brick * 0 64 o_brick * 0 96 o_brick * 0 128 o_brick * 0 160 o_brick * 0 192 o_brick * 0 224 o_brick * 0 256 o_brick * 0 288 o_brick * 0 320 o_brick * 0 352 o_brick * 0 384 o_brick * 0 416 o_brick * 0 448 o_brick * 32 448 o_brick * 64 448 o_brick * 96 448 o_brick * 128 448 o_brick * 160 448 o_brick * 192 448 o_brick * 224 448 o_brick * 256 448 o_brick * 288 448 o_brick * 320 448 o_brick * 352 448 o_brick * 384 448 o_brick * 416 448 o_brick * 448 448 o_brick * 480 448 o_brick * 512 448 o_brick * 544 448 o_brick * 576 448 o_brick * 608 448 o_brick * 608 416 o_brick * 608 384 o_brick * 608 352 o_brick * 608 320 o_brick * 608 288 o_brick * 608 256 o_brick * 608 224 o_brick * 608 192 o_brick * 608 160 o_brick * 608 128 o_brick * 608 96 o_brick * 608 64 o_brick * 608 32 o_brick * 608 0 o_brick * 32 0 o_brick * 576 0 o_brick * 64 0 o_brick * 96 0 o_brick * 128 0 o_brick * 160 0 o_brick * 32 32 o_brick * 576 32 o_brick * 32 64 o_brick * 32 96 o_brick * 32 128 o_brick * 32 160 o_brick * 32 192 o_brick * 32 224 o_brick * 32 256 o_brick * 32 288 o_brick * 32 320 o_brick * 32 352 o_brick * 32 384 o_brick * 32 416 o_brick * 576 64 o_brick * 576 96 o_brick * 576 128 o_brick * 576 160 o_brick * 576 192 o_brick * 576 224 o_brick * 576 256 o_brick * 576 288 o_brick * 576 320 o_brick * 576 352 o_brick * 576 384 o_brick * 576 416 o_brick * 192 0 o_brick * 224 0 o_brick * 256 0 o_brick * 288 0 o_brick * 320 0 o_brick * 352 0 o_brick * 384 0 o_brick * 416 0 o_brick * 448 0 o_brick * 480 0 o_brick * 512 0 o_brick * 544 0 o_brick * 64 32 o_brick * 96 32 o_brick * 128 32 o_brick * 160 32 o_brick * 192 32 o_brick * 224 32 o_brick * 256 32 o_brick * 288 32 o_brick * 320 32 o_brick * 352 32 o_brick * 384 32 o_brick * 416 32 o_brick * 448 32 o_brick * 480 32 o_brick * 512 32 o_brick * 544 32 o_brick * 64 416 o_brick * 96 416 o_brick * 128 416 o_brick * 160 416 o_brick * 192 416 o_brick * 224 416 o_brick * 256 416 o_brick * 288 416 o_brick * 320 416 o_brick * 352 416 o_brick * 384 416 o_brick * 416 416 o_brick * 448 416 o_brick * 480 416 o_brick * 512 416 o_brick * 544 416 o_brick * 64 64 o_brick * 96 64 o_brick * 128 64 o_brick * 160 64 o_brick * 192 64 o_brick * 224 64 o_brick * 256 64 o_brick * 288 64 o_brick * 320 64 o_brick * 352 64 o_brick * 384 64 o_brick * 416 64 o_brick * 448 64 o_brick * 480 64 o_brick * 512 64 o_brick * 544 64 o_brick * 544 96 o_brick * 544 128 o_brick * 544 160 o_brick * 544 192 o_brick * 544 224 o_brick * 544 256 o_brick * 544 288 o_brick * 544 320 o_brick * 544 352 o_brick * 544 384 o_brick * 512 384 o_brick * 480 384 o_brick * 448 384 o_brick * 416 384 o_brick * 384 384 o_brick * 352 384 o_brick * 320 384 o_brick * 288 384 o_brick * 256 384 o_brick * 224 384 o_brick * 192 384 o_brick * 160 384 o_brick * 128 384 o_brick * 96 384 o_brick * 64 384 o_brick * 64 352 o_brick * 64 320 o_brick * 64 288 o_brick * 64 256 o_brick * 64 224 o_brick * 64 192 o_brick * 64 160 o_brick * 64 128 o_brick * 64 96 o_brick * 96 96 o_brick * 128 96 o_rock1 * 160 96 o_rock1 * 192 96 o_rock1 * 224 96 o_rock1 * 256 96 o_rock1 * 288 96 o_brick * 288 128 o_brick * 320 96 o_dirt * 352 96 o_dirt * 384 96 o_dirt * 416 96 o_dirt * 448 96 o_rock1 * 480 96 i_itemb * 512 96 o_dirt * 128 128 o_dirt * 160 128 i_itemb * 192 128 i_itemb * 224 128 i_itemb * 256 128 o_dirt * 96 128 o_brick * 320 128 o_dirt * 352 128 o_rock1 * 384 128 o_dirt * 416 128 o_dirt * 448 128 i_itemb * 480 128 o_dirt * 512 128 o_dirt * 96 160 o_brick * 128 160 o_dirt * 160 160 o_rock1 * 192 160 o_rock1 * 224 160 o_rock1 * 256 160 o_dirt * 288 160 o_dirt * 320 160 o_dirt * 352 160 o_brick * 384 160 o_rock1 * 416 160 o_brick * 448 160 o_rock1 * 480 160 o_rock1 * 512 160 i_itemb * 512 192 i_itemb * 96 192 o_brick * 128 192 o_dirt * 160 192 miner * 192 192 i_itemb * 224 192 o_rock1 * 224 224 o_rock1 * 256 224 o_rock1 * 288 224 o_rock1 * 160 224 o_brick * 128 224 i_itemb * 128 256 i_itemb * 96 224 o_brick * 96 256 o_doora * 128 288 o_brick * 192 352 o_brick * 96 288 o_dirt * 96 320 o_dirt * 96 352 o_dirt * 128 352 o_dirt * 160 352 o_dirt * 160 320 o_dirt * 128 320 o_dirt * 192 288 i_itemb * 224 256 i_itemb * 256 256 i_itemb * 288 256 i_itemb * 288 320 i_itemb * 256 320 o_brick * 320 320 o_brick * 320 288 o_brick * 320 256 o_brick * 320 224 o_brick * 352 288 o_brick * 384 224 o_brick * 416 224 o_brick * 416 256 o_brick * 416 288 o_brick * 416 320 o_brick * 480 192 o_rock1 * 480 224 o_rock1 * 448 224 o_rock1 * 448 256 o_rock1 * 448 288 o_rock1 * 480 288 o_rock1 * 480 320 o_rock1 * 480 256 i_itemb * 384 256 i_itemb * 384 288 i_itemb * 384 320 i_itemb * 448 192 i_itemb * 384 192 i_itemb * 256 192 o_dirt * 288 192 o_dirt * 320 192 o_dirt * 352 192 o_dirt * 416 192 o_dirt * 512 224 o_dirt * 512 256 o_dirt * 512 288 o_dirt * 512 320 o_dirt * 512 352 o_dirt * 480 352 o_dirt * 448 352 o_dirt * 448 320 o_dirt * 416 352 o_dirt * 384 352 o_dirt * 352 352 o_dirt * 352 320 o_dirt * 320 352 o_dirt * 288 352 o_dirt * 256 352 o_dirt * 224 352 o_dirt * 224 320 o_dirt * 192 320 o_dirt * 160 288 o_dirt * 160 256 o_dirt * 192 256 o_dirt * 192 224 o_dirt * 224 288 o_dirt * 256 288 o_dirt * 288 288 o_dirt * 352 224 o_dirt * 352 256 o_dirt * 1 0 0 640 480 dirtbground The max size any of these files will get is 20kb, anything larger is supposed to return an error. Here's part of my php script function HandleForum() { global $msg; if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { //if($_FILES['userfile']['size'] > 50000) // $msg = "Error: Your file is too large."; //elseif($_FILES['userfile']['size'] < 200) // $msg = "Error: Your file is too small."; //elseif(substr($_FILES['userfile']['name'],-4) != ".lnd") // $msg = "Error: .lnd file only"; //else //{ //$fileData = file_get_contents($_FILES['userfile']['tmp_name']); //CreateMap($fileData); //} echo $msg; return; } echo "<h2>Zelda Miner Uploader</h2><br><p>"; echo "<form name = 'zmupload' action = '#' method = 'POST' enctype='multipart/form-data'>"; echo "<input name='MAX_FILE_SIZE' value='5000000' type='hidden'/>"; echo "<input name='userfile' type='file'/>"; echo "<input type='submit' value = 'Upload' name = 'fsubmit'/><br>"; echo "File Type: .lnd<br>"; echo "Max Size: 50 kilobytes<br>"; echo "Info: All tiles must be aligned in a grid.<br>Please have one player and one finish door.<br>If your screen is not a decent puzzle it will be deleted."; echo "</form>"; } ?> Yes, I know my size limit is wrong, but doubt that's the problem since I had large files return error messages like it's suspoed to. Quote Link to comment Share on other sites More sharing options...
Stuie_b Posted October 31, 2009 Share Posted October 31, 2009 The file uploads and it's contents are output without problems for me.. without knowing how CreateMap does it's setup i cant help.. if you can post the CreateMap() function so i can see how $map is setup, Stuie Quote Link to comment Share on other sites More sharing options...
KingOfHeart Posted October 31, 2009 Author Share Posted October 31, 2009 Shouldn't matter since I comments it out and it still does the same thing. Some bugs are just so weird. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 31, 2009 Share Posted October 31, 2009 For troubleshooting, display exactly what you are getting - echo "<pre>"; echo "POST:"; print_r($_POST); echo "FILES:"; print_r($_FILES); echo "</pre>"; Quote Link to comment Share on other sites More sharing options...
KingOfHeart Posted October 31, 2009 Author Share Posted October 31, 2009 That's helpful. After looking up the error codes I found out that it went over the max upload limit for php.ini. I was confused at first but then I noticed that I accidentally removed the letter M in my php.ini. Hmm, I wonder if this was a reason why my multi-uploader was acting strange in the past. Oh well, at least I can now move forward, thanks. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 31, 2009 Share Posted October 31, 2009 ALL code that handles user supplied data MUST validate the data and check for ALL possible errors. If your code already had logic in it to check the ['error'] element of the uploaded file, it (your code) would have told you why it was failing. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.