File Upload ---Thanks!
| From: | J . Keith Tew | Date: | Tue, 07 Jan 2003 03:45:26 +0000 |
| Subject: | File Upload ---Thanks! | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-24610@lists.php.net to get a copy of this message | ||
Thanks folks - persistence pays off and so does group discussions . I had chmodded the uploads directory to 777 but it was within the public_html directory with different file permissions so I guess public_html permissions were taking presidence. After reading all of your suggestions... a little light turned on and I moved the uploads directory outside of the public-html directory and Volia!
Uploading file...
File uploaded successfully
Preview of uploaded file contents:
THIS IS A TEST.........
Thanks Again.
Anyone using a Macintosh with MySql? That is my next goal.
On Monday, January 6, 2003, at 01:16 AM, Steve Khou wrote:
It looks like a directory-write error. Try chmodding the uploads directory to 777. -----Original Message----- From: J. Keith Tew [mailto:jktew@bbnp.com] Sent: Sunday, January 05, 2003 8:41 PM To: php-db@lists.php.net Subject: [PHP-DB] Flat File Upload..HELP!I know this is not technically a DB question but thought someone maybeable to help with this. I have tried everything I could think of tomakethis script work but I keep getting the error message below. I've even changed the permissions on the files and the folders affected toallowfull 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 orifit 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 ERROR MESSAGE 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 UPLOAD SCRIPT <htm <head> <title>Uploading...</title> </head> <body> <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." ".$userfile_type."<br>"; */ if ($userfile=="none") {-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpecho "Problem: no file uploaded"; exit;} if ($userfile_size==0) {echo "Problem: uploaded file is zero length"; exit;} if ($userfile_type != "text/plain") {echo "Problem: file is not plain text"; exit;} $upfile = "/home/design/public_html/uploads/".$userfile_name; if ( !copy($userfile, $upfile)) {echo "Problem: Could not move file into directory"; exit;} 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); fclose($fp); echo "Preview of uploaded file contents:<br><hr>"; echo $contents; echo "<br><hr>"; ?> </body> </html>