The second argument to copy() function cannot be a directory

Posted by Jorm on Stack Overflow See other posts from Stack Overflow or by Jorm
Published on 2010-04-11T19:38:26Z Indexed on 2010/04/11 19:43 UTC
Read the original article Hit count: 413

Filed under:

Anyone know why this:

    $title = trim($_POST['title']);
    $description = trim($_POST['description']);

    // Array of allowed image file formats 
    $allowedExtensions = array('jpeg', 'jpg', 'jfif', 'png', 'gif', 'bmp');

    foreach ($_FILES as $file) {
    if ($file['tmp_name'] > '') {
      if (!in_array(end(explode(".",
            strtolower($file['name']))),
            $allowedExtensions)) {
  echo '<div class="error">Invalid file type.</div>';
      }
    }
    }

 if (strlen($title) < 3)
  echo '<div class="error">Too short title</div>';
    else if (strlen($description) > 70)
     echo '<div class="error">Too long desccription.</div>';

 else {
   move_uploaded_file($_FILES['userfile']['tmp_name'], 'c:\wamp\www\uploads\images/');
 }

Gives:

Warning: move_uploaded_file() [function.move-uploaded-file]: The second argument to copy() function cannot be a directory in C:\wamp\www\upload.php on line 41
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\wamp\tmp\php1AB.tmp' to 'c:\wamp\www\uploads\images/' in C:\wamp\www\upload.php on line 41

© Stack Overflow or respective owner

Related posts about php