desithugg Posted February 22, 2007 Share Posted February 22, 2007 <head> #############The Upload form file######################### <script src="multifile_compressed.js"></script> </head> <body> <form enctype="multipart/form-data" action="index.php?action=uploadimage2" method = "post"> <input size="50" id="my_file_element" type="file" name="images[]" > <input type="submit" value="Upload"> </form> Files: <div id="files_list"></div> <script> var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 10 ); multi_selector.addElement( document.getElementById( 'my_file_element' ) ); </script> </body> The code above is just a basic php upload form which uses javascript to upload multiple files using only one field <? #############The Upload action file######################### $username = $_COOKIE['username']; while(list($key,$value) = each($_FILES[images][name])) { if(!empty($value)) { srand((double)microtime()*1000000); $rand = rand(0,9999999); $rand2 = rand(0,999); $filename = $value; $add = "upimg/".$rand."".$username"".$rand2.".$filename"; if(file_exists($_FILES[images][tmp_name][$key]) OR file_exists($add) { $error = $_FILES[images][type][$key]." already exists in the database.<br>"; } if($error == "") { echo $_FILES[images][type][$key]." uploaded!"; echo "<br>"; copy($_FILES[images][tmp_name][$key], $add); chmod("$add",0777); } else { echo $error; } } } ?> Now that's the code that handles the image upload but now what I want to do is make sure that all the images uploaded are less than 550px in width how can I do that, I'm not sure how to get the image size of the uploaded files. thanks in advace I g2g right now please try and help me out as quick as possible, kind of in a hurry. Link to comment https://forums.phpfreaks.com/topic/39706-php-multiple-image-upload/ Share on other sites More sharing options...
Ninjakreborn Posted February 22, 2007 Share Posted February 22, 2007 $_FILES['filename']['size'] This contains a value, that valued contained therein is the size of the image. Or get_image_size($image); it's actually better because it returns the type and everything else in a massive and very helpful array. Link to comment https://forums.phpfreaks.com/topic/39706-php-multiple-image-upload/#findComment-191706 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.