Forum Moderators: coopster
$uploadfile = $uploaddir . basename($_FILES['nume_fis']['name']);
if (move_uploaded_file($_FILES['nume_fis']['tmp_name'], $uploadfile))
{echo "File is valid, and was successfully uploaded.\n";} else { }
The problem with the script is that it overwrites the file uploaded one day before. How can I do to merge the content of all uploaded files in a single file, so at the end of the week I can see all data that I have uploaded?
Note: the file that I upload in not TXT but binary. I am beginner in PHP :)
Thanks
$newfile = $_FILES['nume_fis']['tmp_name'];
$uploadfile = $uploaddir . basename($_FILES['nume_fis']['name']);
if( is_readable($newfile) && is_readable($uploadfile) ) { //If the old file exists and is readable
$result = file_put_contents($uploadfile, file_get_contents($uploadfile) . file_get_contents($newfile) ); //Appending new data and writing to file
} else {
$result = move_uploaded_file($newfile, $uploadfile);
}
if($result !== false) {
echo "File is valid, and was successfully uploaded.\n";
}
but there is a problem. The script above inserts an ENTER between records when it appends the files, breaking my binary format.
Any ideas how to get rid of this.
PS: Also, somebody suggested to use FILE_APPEND flag.