[imp] Attachment corruption problem

Daniel A. Ramaley daniel.ramaley at DRAKE.EDU
Wed Apr 26 08:56:30 PDT 2006


On Tuesday 25 April 2006 16:24, Jan Schneider wrote:
>The encoding is not the source of the problem, the mime type is, like
>I said. The browser is uploading the attachment with a text mime type,
>thus we encode in quoted printable. Only binary attachments are (and
>should be) encoded in base64.

I've done some tests on my PHP installation to determine how the browser 
uploads files. The problematic file is uploaded with a type of 
application/octet-stream, which would seem to be a binary type.

The way i determined the mime type that the browser sends was to create 
two files on the server, form.html and form.php as follows:

<!-- form.html -->
<html><head></head><body>
<form enctype="multipart/form-data" action="form.php" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
    Send this file: <input name="userfile" type="file" />
    <input type="submit" value="Send File" />
</form>
</body></html>

<!-- form.php -->
<?php
echo '<pre>';
print_r($_FILES);
echo passthru("ls -l {$_FILES[userfile][tmp_name]}");
echo passthru("md5sum {$_FILES[userfile][tmp_name]}");
echo '</pre>';
?>

I browse to form.html and upload the file that Imp corrupts. The output 
of form.php is:

Array
(
    [userfile] => Array
        (
            [name] => DU41.PAK
            [type] => application/octet-stream
            [tmp_name] => /var/tmp/phpu7O6Sb
            [error] => 0
            [size] => 16919
        )

)
-rw-------  1 apache apache 16919 Apr 26 10:39 /var/tmp/phpu7O6Sb
aef5ca0e5d56df5dcaf3cf7fe5975d74  /var/tmp/phpu7O6Sb

The file size in the ls listing, and the MD5 sum both match the original 
file. So i know the file can get to the server without corruption. 
Therefore Imp must be corrupting the file when it encodes it. I'm just 
trying to get Imp to correctly choose a binary encoding so the file 
won't be corrupted. Is there a way to do that?

------------------------------------------------------------------------
Dan Ramaley                            Dial Center 118, Drake University
Network Programmer/Analyst             2407 Carpenter Ave
+1 515 271-4540                        Des Moines IA 50311 USA


More information about the imp mailing list