I'm using PHP version 4.2.2 on a Linux system running Apache.  I am
trying to allow my users to upload a file, however I continue to receive a
"Permission denied" error when using move_uploaded_file() or copy().  The
file appears to be sent to the temporary directory successfully, but can not
be copied or moved to the uploads directory.
    I've used the following code to authenticate (I enter in the same
username and password that I use for ftp -- which has the necessary
permissions to move/copy files to the destination);

--------------------------------------------------------------------------
<?php

  if (!isset($_SERVER['PHP_AUTH_USER'])) {
 header('WWW-Authenticate: Basic realm="Private"');
 header('HTTP/1.0 401 Unauthorized');
 echo "Authentication failed.\n";
 exit;
  }
  else {
 echo "<p>Welcome: {$_SERVER['PHP_AUTH_USER']}</p><br>";
 echo "<p><form enctype='multipart/form-data' action='fileUpload.php'
method='post'>\n";
 echo "<input type='hidden' name='MAX_FILE_SIZE' value='30000'>\n";
 echo "Send this file: <input name='userfile' type='file' >\n";
 echo "<input type='submit' value='Send File'>\n";
 echo "</form></p>\n";
  }
?>
--------------------------------------------------------------------------

The code for fileUpload.php is as follows;

<?php

  $src = $_FILES['userfile']['tmp_name'];
  $dest = './characters/images/'.$_FILES['userfile']['name'];

  echo "<p>Welcome: {$_SERVER['PHP_AUTH_USER']}<br>";
  echo "The file was temporarily uploaded to:
".$_FILES['userfile']['tmp_name']."<br>";

/*
  $result = move_uploaded_file($src, $dest);
*/

  $result = copy($src, $dest);

  echo $result;

?>
--------------------------------------------------------------------------

Could someone help me to get this working?  I'd appreciate it.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to