Multiple image upload validation not working! Please Help !! URGENT!

In this code to upload multiple images to a different folder each time, it creates a new folder and moves files to it, but the validation part is not working ! if i remove the validation part the files are uploaded correctly!!

I have mentioned using comments that in which area the problem i think is coming!

If someone can then please help!

the error is:

Warning: strtolower() expects parameter 1 to be string, array given in C:\xampp\htdocs\upload-file.php on line 66

Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\upload-file.php on line 66

here’s the code:
[php]

<?php $contact_name = $_POST['contact_name']; $id=rand(1,9999999); //this will give us a random value to create a unique directory if(!is_dir("uploads/".$id)){ //this checks to make sure the directory does not already exist mkdir("uploads/".$id.$contact_name, 0777, true); //if the directory doesn't exist then make it chmod("uploads/".$id, 0777); //chmod to 777 lets us write to the directory } $uploaddir='uploads/' . $id.$contact_name.'/'; //lets put the directory into a variable notice added slash on end foreach($_FILES["uploads"]["name"] as $bla=> $boo){ //we have to do a loop to get all the filenames $file=$uploaddir.$boo; //we will check the filename in the upload directory, see if it exists if (file_exists($file)) { //if it exists then ...... die("Filename already exists, please rename this file"); //if filename exists in the directory then we die!!! :P } } foreach ($_FILES["uploads"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { echo"$error_codes[$error]"; // let you know if there was an error on any uploads move_uploaded_file( //php function to move the file $_FILES["uploads"]["tmp_name"][$key], //from the temporary directory $uploaddir. $_FILES["uploads"]["name"][$key] //to the directory you chose ) or die("Problems with upload"); } } /* THE PROBLEM IS IN HERE SOMEWHERE BECAUSE WHEN I REMOVE THIS PART, THE SCRIPT RUNS SUCCESSFULLY */ $allowedExtensions = array("jpg","jpeg","gif","png"); foreach ($_FILES as $file) { if ($file['tmp_name'] > '') { if (!in_array(end(explode(".", strtolower($file['name']))), $allowedExtensions)) { die($file['name'].' is an invalid file type!
'. ''. '<&lt Go Back'); } } } [/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service