Hello all,
This is the synopsis: the PHP code is an interpreter of commands given in a terminal-like fashion, so as a string. Basically PHP receives a string argument, interprets it based on a given regular expression and then execute it. Here, the code receives a string similar to
ftp>fput -file(contents-of-file)
In this case, the code will ftp-fput a string to a given server. Works fine when file is ASCII. Now if the file is binary (ie, an image), the regex will bug and even if it wouldnt I want to encode the binary contents of the file so it can fit into the command string. I then need to be able to decode it on the interpreter side. I've tried base64 encode/decode, hex2bin bin2hex, pack unpack, but the file ftp'd always ends up not being readable by browser. The generated file, when attempted to be opened on Linux, generates an error like
Fatal error reading PNG image file: PNG file corrupted by ASCII-conversion
Any suggestions or clarification requests welcome,
Thanks