I keep getting write errors when running the following script. The purpose of the script is to upload all files of one directory into another ftp server. However I keep having problems. Like it works once, and then it doesn't work, giving a write error such as this:
Warning: ftp_put(): Write error (se=0, pe=1015). Transfer aborted. in /home/the/public_html/mysql/uploadtest.php on line 337
or saying it was "ready to receive the file"
any ideas?
//Make a directory on alternate servers for files to be uploaded to
ftp_chdir ($conn_id, $_GET[type]);
$mkdir = ftp_mkdir ($conn_id, $_GET[dirname]) or die("<br>There was an error- you have come here from the wrong place.");
ftp_chdir ($conn_id, $_GET[dirname]);
//Opens directory that contained files uploaded by user, which will be uploaded to the alternate ftp server
$dir = "temp$_GET[dirname]/";
$files = array();
$open = opendir($dir);
while ($file = readdir($open)) { if ($file != "." && $file != "..") { $files[] = $file; } }
closedir($open);
sort($files);
reset($files);
//uploads each file in that directory to the server
for ( $i=0; $i < count($files); $i++ ) {
//Upload
$source_file="temp$_GET[dirname]/$files[$i]";
$destination_file="$files[$i]";
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
unlink($source_file);
}