RE: [PHP] Permission denied

From: Date: Fri, 23 Mar 2001 17:16:42 +0000
Subject: RE: [PHP] Permission denied
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-45317@lists.php.net to get a copy of this message
Whoopee!!! After two days of propeller-spinning, I finally uploaded a file successfully!!! I had to use an FTP connection to do it, because my PHP process didn't have permission to write files to my directory, but that's fine. Here's the code snippet that worked the trick, with my servername/username/password changed to protect the innocent (me!) Thanks to Adam for putting me on the right track, vis-a-vis file permissions. John ================================= echo ("$userfile<br>"); echo ($HTTP_POST_FILES['userfile']['name'] ."<br>"); echo ($HTTP_POST_FILES['userfile']['type'] ."<br>"); echo ($HTTP_POST_FILES['userfile']['size'] ."<br>"); echo ($HTTP_POST_FILES['userfile']['tmp_name'] ."<br>"); //============================= // FTP //============================= $ftp_server = "server.name.com"; $ftp_user_name = "username"; $ftp_user_pass = "password"; // open source file if ($fd = fopen($userfile, "r") or die ("Can't open file $src<br>")) print("opened file $userfile<br>"); else die("couldn't open src file $src<br>"); // set up basic FTP connection $conn_id = ftp_connect("$ftp_server"); // login with username and password $login_result = ftp_login($conn_id, "$ftp_user_name", "$ftp_user_pass"); // check connection if ((!$conn_id) || (!$login_result)) echo "Ftp connection has failed!<br>"; echo "Attempted to connect to $ftp_server for user $user<br>"; die; } else { echo "Connected to $ftp_server, for user $ftp_user_name<br>"; } if (ftp_fput($conn_id, "testfile.txt", $fd, FTP_BINARY)) { print("ftp_fput success!!!<br>"); } else { print("ftp_put failure!!!<br>"); } ftp_quit($conn_id); fclose($fd); //================================

« previous php.general (#45317) next »