Re: Creating thumbnails using Image Functions, then saving to folders
| From: | tedd | Date: | Tue, 24 Oct 2006 13:41:20 +0000 |
| Subject: | Re: Creating thumbnails using Image Functions, then saving to folders | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-243574@lists.php.net to get a copy of this message | ||
Chris asked:
Is there a way to use a php FTP function to FTP the file out of the buffer to a directory on the server, or some other way to write a file to a folder without making that folder 0777?What about changing the folder's permission to 0777 during the operation and then changing it back after? That's what I have to do with my virtual host. The following is a demo I wrote that you might want to review. hth's tedd --- // how to call the function <?php $ftp_path = "public_html/rw/"; // note the ftp path $theDir = "tmp"; $theFile ="text.txt"; FtpPerms($ftp_path, $theDir, $theFile); ?> // the function <?php // create directory and change perms via FTP connection function FtpPerms($path, $theDir, $theFile) { $server='ftp.yourdomain.com'; // ftp server $connection = ftp_connect($server); // connection $user = "you"; $pass = "yourpassword"; $result = ftp_login($connection, $user, $pass); // login to ftp server if ((!$connection) || (!$result)) { echo("No connection<br/>"); return false; exit(); } else { echo("Made connection<br/>"); ftp_chdir($connection, $path); // go to destination dir echo("Change Perms<br/>"); $str="CHMOD 0755 " . $theDir; // change perms for dir (note the space after 0775 ) ftp_site($connection, $str); echo("$str<br/>"); $filename = "$theDir/$theFile"; $contents = "This is the contents of the file."; echo("<hr><br/>Writing file <br/><br/>"); $file = fopen( $filename, "w" ); fwrite( $file, $contents); fclose( $file ); chmod($filename,0777); echo("Change Perms<br/>"); $str="CHMOD 0600 " . $theDir; // change perms back for dir ftp_site($connection, $str); echo("$str<br/>"); echo("Close connection<br/>"); ftp_close($connection); // close connection } } ?> -- ------- http://sperling.com http://ancientstones.com http://earthstones.com