This is a synopsis: PHP code is an interpreter of commands given in a terminal way, so this is a string. Basically, PHP receives a string argument, interprets it based on a given regular expression, and then executes it. Here the code gets a line similar to
ftp>fput -file(contents-of-file)
In this case, the code will transfer ftp-fput to the specified server. It works fine when the ASCII file. Now, if the file is binary (that is, an image), the regular expression will be an error, and even if I did not want to encode the binary contents of the file so that it could fit into the command line. Then I should be able to decode it on the interpreter side. I tried to encode / decode base64, hex2bin bin2hex, unpack the package, but the ftp'd file is not always read by the browser. The generated file when trying to open on Linux generates an error, for example
Fatal error reading PNG image file: PNG file corrupted by ASCII-conversion
Any suggestions or clarifications are welcome,
thank
source
share