Hello,
Is use this code to copy a file from my server to another one. But it fails when the file on the other server already excists... The first time it is succesfull, next time I get the "fopen error"-message
So I need to delete te file first. Can anybody help me out ? (ps: I cannot use the PHP-FTP functions)
$FileUp = $exportDir."/".$FileName;
//Open the uploaded pic (temp file)
if ($FileOpen = fopen ($FileUp, "rb"))
{
//read temp file into var
$saveFile = fread($FileOpen, filesize($FileUp));
//Open a new file in the correct directory using the name of uploaded file
$UploadLocation = "ftp://".$FTP_accountname.":".$FTPpass."@".$FTPloc."/".$FileName;
if ($fileHandle = fopen($UploadLocation, "w"))
{
//Put data into just opened file pointer
if (fwrite ($fileHandle, $saveFile))
echo "file <b>$FileUp</b> successfully written";
else
echo "file <b>$FileUp</b> was NOT written";
}
else
{
echo "fopen error";
}
}
else
{
// The file was not created. Inform the user.
echo ("<b> The file: $FileUp could not be created!</b>");
}