$upload_ok = false; // assume false if(isset($_FILES['filename_normal'])) { $thefile = $_FILES['filename_normal']; // grab the array // just a quick test, better to validate with getimagesize() switch(strtolower($thefile)) { case 'image/gif': case 'image/pjpeg': case 'image/jpeg': case 'image/jpg': $upload_ok = true; break; deafult: echo 'Invalid file type'; break; } if ($upload_ok) { if(is_uploaded_file($thefile['tmp_name']) == true ) { $file_from = $thefile['tmp_name']; $file_to = 'images/uploads/'. $thefile['name']; if(move_uploaded_file($file_from, $file_to) ) { $sql .= ' ,imgname = \''. DBUploadDir . mysql_real_escape_string($file_to) . '\''; chmod($file_to, 0644); // dont need this } else { echo 'move failed'; } } else { echo 'Invalid upload'; } } } else { // nothing was submitted via the form }