Don't know why or where, but you've got some utf8 encoding going on.
EF,BF,BD is the utf8 "replacement string" used for an unknown character
(probably the initial FF).
Suggest you sniff your data stream to see if it's happening before it
reaches Embperl.
On 04/04/2012 17:20, Jean-Christophe Boggio wrote:
Hello,
I have a simple upload module but I can't get a pure binary upload
to work everytime. This is what I get sometimes :
- Original is 73856 bytes
- Uploaded is 33398 bytes or 27939 bytes
Also the header changed from :
0x00000000: FFD8FFE0 00104A46 49460001 0101012C ......JFIF.....,
To :
0x00000000: EFBFBDEF BFBD0010 4A464946 00010101 ........JFIF....
0x00000010: 012C .,
Or even :
0x00000000: EFBFBDEF BFBDEFBF BDEFBFBD 00104A46 ..............JF
0x00000010: 49460001 0101012C IF.....,
So it's not just a truncated file. What is doing this ? Why does it
work sometimes
and sometimes not ?
I have tried setting escmode=0, binmode FILE, EmbperlBlocks with no
change. What is
causing this behaviour ? How can I guarantee a binary upload ?
Here is my code :
[$ syntax EmbperlBlocks $]
[-
$req=shift;
$escmode=0;
$PHOTOPATH = "$ENV{DOCUMENT_ROOT}/data/img/artistes/big";
while ( ($k,$v)=each(%fdat)) {
if ($k =~ /^upl(\d+)$/ and $v) {
my $filename=$1;
open(FILE,">$PHOTOPATH/$filename.jpg") or print OUT $!;
binmode FILE;
my $buffer;
while (read($fdat{$k},$buffer,32768)) {
# should I do something with $buffer here ?
print FILE $buffer;
}
close(FILE);
}
}
-]
<form method="post" ENCTYPE="multipart/form-data">
And inside a loop :
<input type="FILE" id="upl[+ $p->[0] +]" name="upl[+ $p->[0] +]" />
<input type="SUBMIT" name="Bsave" value="Enregistrer" />
</form>
Thanks for your help,
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscr...@perl.apache.org
For additional commands, e-mail: embperl-h...@perl.apache.org