FTP/PHP
| From: | webmaster at morningstarstudios dot net | Date: | Mon, 21 Aug 2000 00:34:46 +0000 |
| Subject: | FTP/PHP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-12695@lists.php.net to get a copy of this message | ||
Im attempting to read from a file, then make the file empty (0 bytes). Im using the following code:
# Initialize File/Contents
$fp = fopen('ftp://$ftp_username:$ftp_password@$ftp_url/$mail_dir/$mail_username',
'r');
$contents = fread($fp, 80000);
fclose ($fp);
############## Clear Mail File
$fp = fopen('ftp://$ftp_username:$ftp_password@$ftp_url/$mail_dir/$mail_username',
'a');
ftruncate($fp, 0);
fclose ($fp);
################
Assuming the variables are set correctly, the read from file works fine. But when I added the
truncate portion of code, I got:
Warning: File already exists in /home/morning/morningstarstudios-www/secure/email/support/index.php
on line 23
Warning: fopen('ftp://...@ftp.morningstarstudios.net/morningstarstudios-mail/support','a')
- File exists in ****(filename)**** on line 23
I know the file exists, but how do I get around this error, and rewrite the file with 0 length?
Thanks,
Matthew Walkup
webmaster@morningstarstudios.net