PHP - How On Earth..
How on earth I'm supposed to use UPLOAD_ERR_INI_SIZE or UPLOAD_ERR_FORM_SIZE when $_FILES is empty due to an over-sized file?
ie: Code: [Select] echo $_FILES['file_upload']['error']; Will not work when the file is too large, rendering UPLOAD_ERR_INI_SIZE and UPLOAD_ERR_FORM_SIZE useless.. Similar TutorialsHi everyone! I'm on a mission to make a simple (I hope :/ ) script that takes some files from a folder and sends them off to a snippet of javascript. I have a folder creatively named 'files' that is full of Google Earth .kml files. I want to get some PHP code to grab those files, and pass them to the javascript that handles the Google Earth plugin, which looks like this: Code: [Select] var link = ge.createLink(''); var href = '<?php echo($testvar); ?>' link.setHref(href); var networkLink = ge.createNetworkLink(''); networkLink.set(link, true, true); The php in there is me testing out php-to-javascript variables, which seems to be working fine for a single file. My plan for the code was to: 1) Detect all the files in the folder 2) Make the paths for each file into string variables 4) Loop the above javascript once for each file The end result would be the kml files, which are all building models, populating the earth. The files in the folder will be added and removed all the time, so It has to check it every time. Unfortunately this had to be my first experience with php and so this is as far as I got: foreach(glob("files/"."*.kml") as $file){ echo $file." - "; } So, it lists out the files in the directory with a ' - ' between each one, but from there I've been lost for days Does anyone have some pointers on what to do with this? Thanks, Love ya! Hello!
I was assigned to create a simple php game as a part of my grade. I'm not really a php expert and this isnt really working. I copied some of the code from this website, but this isn't really working for me. I don't really know how to solve the problem and connect that two files.
Part 1:
<html> <head> <title>PHP based example Game - Earth & Wind & Fire (aka Paper-Scissors-Rock)</title> </head> <body> <center> <div id="game"> <a href="?item=earth">Earth<br /><img src="images/sand.png" width="135" height="135" alt="Earth"></a><br /><a href="?item=wind">Wind<br /><img src="images/wind.png" width="135" height="135" alt="Wind"></a><br /><a href="?item=fire">Fire<br /><img src="images/fire.png" width="135" height="135" alt="Fire"></a><br /></div> </center> </body> </html>Part 2: <?php function showComponents($items = null) { $pictures = array( "earth" => '<a href="?item=earth">Earth<br /><img src="images/sand.png" width="135" height="135" alt="Earth"></a><br />', "wind" => '<a href="?item=wind">Wind<br /><img src="images/wind.png" width="135" height="135" alt="Wind"></a><br />', "fire" => '<a href="?item=fire">Fire<br /><img src="images/fire.png" width="135" height="135" alt="Fire"></a><br />', ); if ($items == null) : foreach( $pictures as $items => $value ): echo $value; endforeach; else: echo str_replace("?item={$items}", "#", $pictures[$items]); endif; } function game() { if ( isset($_GET['item']) == TRUE ) : $pictures = array('earth','wind','fire'); $playerPic = strtolower($_GET['item']); $computerPic = $pictures[rand(0, 2)]; echo '<div><a href="http://mapswidgets.com/game.php">New game</a></div>'; if (in_array($playerPic, $pictures) == FALSE): echo "Play as either Earth, Wind or Fire."; die; endif; if ( $playerPic == 'fire' && $computerPic == 'wind' OR $playerPic == 'earth' && $computerPic == 'fire' OR $playerPic == 'wind' && $computerPic == 'earth' ): echo '<h2>You Win!</h2>'; endif; if ( $computerPic == 'fire' && $playePic == 'wind' OR $computerPic == 'earth' && $playerPic == 'fire' OR $computerPic == 'wind' && $playerPic == 'earth' ): echo '<h2>Computer wins!</h2>'; endif; if ($playerPic == $computerPic) : echo '<h2>House wins! =)</h2>'; endif; showComponents($playerPic); showComponents($computerPic); else : showComponents(); endif; } ?>Thanks for your time and help! |