Multi File upload form with thumbnail maker not working

Ask about a PHP problem here.
Post Reply
kgdd
Posts: 17
Joined: Fri Nov 04, 2011 2:24 pm

Multi File upload form with thumbnail maker not working

Post by kgdd »

Here is my code, it is not getting past file verification:
if ((($_FILES['multifile']['type'][$key] == "image/png") || 
		 	($_FILES['multifile']['type'][$key] == "image/jpeg") || 
		 	($_FILES['multifile']['type'][$key] == "image/pjpeg")) && 
		 	($_FILES['multifile']['size'][$key] < 2097152))
		{
	
			if(count($_FILES['multifile']['name']) > 0) 
            {
				foreach ($_FILES['multifile']['name'] as $key => $filename)
                {
					
					$filename = time().'_'.$_FILES['multifile']['name'];  
					$source = $_FILES['multifile']['tmp_name'];  
					$target = '/uploads/'.$filename;  
				  
					if(move_uploaded_file ($_FILES['multifile']['tmp_name'][$key],$target))
                	{
						createThumbnail($filename);  
						
						// database insert here
						
						echo '<div class="success" style="margin-right:25px;">Images added, view individual album to edit image descriptions</div>';
					}
				}
			}
		}

		else
		{
			echo '<div class="error">Invalid file, only jpg, jpeg, or png file types allowed</div>';
		}
the input type is file and the name is multifile[]. Any help would be great, thanks!
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Multi File upload form with thumbnail maker not working

Post by jacek »

Well you might want to have a bit of a re-think since $_FILES['multifile']['type'] can very easily be faked by somone looking to upload a php script.

Other than that, what do you mean by the file validatoion ? do you always get the "invalid file" message ?
Image
Post Reply