note 43131 added to function.base64-decode
| From: | paul at ijsfontein dot nl | Date: | Thu, 10 Jun 2004 10:04:06 +0000 |
| Subject: | note 43131 added to function.base64-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-70876@lists.php.net to get a copy of this message | ||
The user notes posted here helped me a lot in writing the PHP code to upload uuencoded files to a
server using $_POST. Hardest thing to figure out was why the files came out scrambled and corrupted.
After comparing the original file with the file reconstructed by the uudecode script, I found out
that a simple "stripcslashes" on the posted data will do the trick.
So, to upload any kind of uuencoded file using a POST:
1. send the raw file data to the PHP script
2. $uuencoded_data = stripcslashes($_POST['filedata']);
3. strip the marker lines from $uuencoded_data (first line, last line and second last line of the
data. Each line is seperated by a LF (chr(10)) character.)
4. $decoded_data = uudecode($stripped_uuencoded_data); (this function can be found in the user notes
here).
5. Use the script provided in one of the user notes on this page to write the decoded data to a
binary file.
That should do the trick!
----
Manual Page -- http://www.php.net/manual/en/function.base64-decode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43131
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43131&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43131&report=yes
Search -- http://master.php.net/manage/user-notes.php