AviNahum Posted May 29, 2010 Share Posted May 29, 2010 hey, i tried to upload a multiple files... this is my code: <?php if(isset($_FILES['images']['tmp_name'])) { // Number of uploaded files $num_files = count($_FILES['images']['tmp_name']); for($i=0; $i < $num_files;$i++) { $random = rand(0,1000000000000000000); $_FILES["images"]["name"][$i] = "".$random."_".$_FILES["images"]["name"][$i].""; $type = $_FILES["images"]["type"][$i]; $at = array("image/gif", "image/jpeg", "image/pjpeg", "image/png", "image/x-png"); // We allow only images file types if (!in_array($type, $at) ) return $core->error("אחד הקבצים או יותר שהעלת אינם בפורמט מתאים."); if ($_FILES["images"]["name"][$i] > 0) return $core->error("{$_FILES["images"]["name"][$i]}"); move_uploaded_file($_FILES["images"]["name"][$i], "images/projects/" . $_FILES["images"]["name"][$i]); $_POST['images'] .= $_FILES["images"]["name"][$i].","; } } ?> for some reason move_uploaded_file doesnt work... it's just not moving the files to this directory... the folder i trying to upload the files has 777 permissions so thats not the problem... any ideas? Thanks! Quote Link to comment Share on other sites More sharing options...
teynon Posted May 29, 2010 Share Posted May 29, 2010 I haven't had to deal with that for a while, but I would check that both images and projects are chmodded. In addition, I would put a ' or die("Yup its move_uploaded_file"); on that move statement. You could also check the server PHP error log to see what could be happening. Quote Link to comment Share on other sites More sharing options...
ChaosKnight Posted May 29, 2010 Share Posted May 29, 2010 Yeah, had the same problem last week, then I discovered that it isn't the upload folder that needs permissions, it's the entire folder in which your script that uses the move_uploaded_folder that needs 777... And use: ini_set('display_errors', 1); at the top of your script, to locate the error... Quote Link to comment Share on other sites More sharing options...
AviNahum Posted May 29, 2010 Author Share Posted May 29, 2010 i chmodded everythink... and it's dies on move_uploaded_file... this code works great with single file upload... Quote Link to comment Share on other sites More sharing options...
teynon Posted May 29, 2010 Share Posted May 29, 2010 Ok, I'm being lazy right now. Can you paste the output of "print_r($_FILES)"? Quote Link to comment Share on other sites More sharing options...
AviNahum Posted May 29, 2010 Author Share Posted May 29, 2010 output of echo "<pre>".print_r($_FILES, true)."</pre>"; Array ( [images] => Array ( [name] => Array ( [0] => -201707379_unix-hd-wallpaper-1.jpg [1] => -1169662749_Ubuntu_Bokeh_by_ttk1opc.png [2] => -699814691_mikro_sine-shape-04-Hi-wallpaper-HD.jpg [3] => -870034778_mikro_sine-shape-04-Hi-wallpaper-HD.jpg ) [type] => Array ( [0] => image/jpeg [1] => image/png [2] => image/jpeg [3] => image/jpeg ) [tmp_name] => Array ( [0] => /tmp/phpWyjLH0 [1] => /tmp/phpcdtSnL [2] => /tmp/phpHguf4v [3] => /tmp/phpUkLILg ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 ) [size] => Array ( [0] => 298835 [1] => 203598 [2] => 886080 [3] => 886080 ) ) ) Quote Link to comment Share on other sites More sharing options...
teynon Posted May 29, 2010 Share Posted May 29, 2010 Welcome to we all missed the obvious.... move_uploaded_file($_FILES["images"]["tmp_name"][$i], "images/projects/" . $_FILES["images"]["name"][$i]); Quote Link to comment Share on other sites More sharing options...
AviNahum Posted May 29, 2010 Author Share Posted May 29, 2010 i could kick myself right now :| Thank you! 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.