Try move_uploaded_file()


J . Keith Tew wrote:

I know this is not technically a DB question but thought someone may be
able to help with this. I have tried everything I could think of to make
this script work but I keep getting the error message below. I've even
changed the permissions on the files and the folders affected to  allow
full read,write execute priviledges to all users ...but still no luck.
I'm not sure if it is a server (apache on linux)  permission issue or if
it is a typo in the script or a file path issue. ANY HELP would be
greatly appreciated.  I've also included the script below in the event
the mistake is in the script

Thanks in Advance


Uploading file...

Warning: Unable to create
'/home/design/public_html/uploads/fbcnews.txt': Permission denied in
/home/design/public_html/uploads/upload1.php on line 35
Problem: Could not move file into directory


<h1>Uploading file...</h1>
   // $userfile is where file went on webserver
   // $userfile_name is original file name
   // $userfile_size is size in bytes
   // $userfile_type is mime type e.g. image/gif

/*  echo "Variables are:<br>";
   echo $userfile." ".$userfile_name." ".$userfile_size."

   if ($userfile=="none")
     echo "Problem: no file uploaded";

   if ($userfile_size==0)
     echo "Problem: uploaded file is zero length";

   if ($userfile_type != "text/plain")
     echo "Problem: file is not plain text";

   $upfile = "/home/design/public_html/uploads/".$userfile_name;

   if ( !copy($userfile, $upfile))
     echo "Problem: Could not move file into directory";

   echo "File uploaded successfully<br><br>";
   $fp = fopen($upfile, "r");
   $contents = fread ($fp, filesize ($upfile));
   fclose ($fp);

   $contents = strip_tags($contents);
   $fp = fopen($upfile, "w");
   fwrite($fp, $contents);

   echo "Preview of uploaded file contents:<br><hr>";
   echo $contents;
   echo "<br><hr>";


PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to