there are two files one of which is a binary (a simple exe file). How can I use PHP to add some textual information to the end of this exe file (for example, from another text file)?
Any file manager seamlessly appends text to the end of the executable file, but is it possible to do using PHP?
UPDATE: Thanks a lot to @arkascha!
$file = 'original_file.exe';
$newfile = 'new_file.exe';
copy($file, $newfile);
$handle=fopen("new_file.exe", "a+");
fwrite($handle, "777777");
fclose($handle);
And we have a working exe file with the text “777777” at its end.
That is certainly possible, although I have no idea what that is meant to result in. All you have to do is open a file for writing, then open the first file for reading, read the content, write it into the file you have for writing and close the first file. Same with the second file. Last you close the file you opened for writing and have a new file that contains the concatenated content of both files. Why shouldn’t that be possible?