Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

truncated file upload under Windows 2000

by uwevoelker (Pilgrim)
on Apr 17, 2002 at 11:18 UTC ( [id://159768]=perlquestion: print w/replies, xml ) Need Help??

uwevoelker has asked for the wisdom of the Perl Monks concerning the following question:

Hello,
I migrated a file upload script from Linux to Windows 2000. Under Linux everything was okay, but under Windows the files are truncated. The last few bytes are missing.
Has this happened to you, before? How can I solve this problem?
I use binmode (image files) and read($fh, $buffer, 1024).

Thank you very much, Uwe
  • Comment on truncated file upload under Windows 2000

Replies are listed 'Best First'.
Re: truncated file upload under Windows 2000
by tachyon (Chancellor) on Apr 17, 2002 at 13:12 UTC

    Hi Uwe,

    s/use CGI/use CGI::Simple/g;

    But seriously if you have a moment to download it could you see if this happens with my CGI.pm substitute CGI::Simple as well? I would be most interested to know. Note you can only substitute CGI::Simple for CGI.pm if you are not using the CGI.pm HTML generating methods. The problem (as previously noted) will probably be related to not applying binmode to STDIN as well as your FH. Perl makes an automagical translation from \n internally to \r\n externally on Win32. This is fine for textfiles but stuffs up binaries (reading and writing) where 00001101 00001010 means just that (ie not \r\n) and should not be converted to 00001010.

    See Also

    CGI::Simple vs CGI.pm - is twice as fast good enough?

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: truncated file upload under Windows 2000
by TheHobbit (Pilgrim) on Apr 17, 2002 at 11:39 UTC
    Hi,

    It's hard to say what's going on with you providing no hint about your script and/or the kind of files it is supposed to handle... Could you give us more details?

    Cheers


    Leo TheHobbit
    GED/CS d? s-:++ a+ C++ UL+++ P+++>+++++ E+ W++ N+ o K? !w O? M V PS+++
    PE-- Y+ PPG+ t++ 5? X-- R+ tv+ b+++ DI? D G++ e*(++++) h r++ y+++(*)
Re: truncated file upload under Windows 2000
by perlplexer (Hermit) on Apr 17, 2002 at 12:37 UTC
    Try to binmode() all filehandles that are being used; i.e., $fh, STDIN, STDOUT.
    And remember that you need to call binmode() before you do any I/O. So, stick
    binmode STDIN; binmode STDOUT;
    somewhere at the beginning of your program and see what happens.

    --perlplexer
Re: truncated file upload under Windows 2000
by uwevoelker (Pilgrim) on Apr 18, 2002 at 14:31 UTC
    I have to apologize!
    The problem was not the file upload. I stored the uploaded images in a mysql database. And the error came from the image view script. Under Linux everything was okay, but under Windows the statement handle ($sth) was still active after the query (SELECT binary FROM picture WHERE id=3) and so a warning occured and was appended to the picture. That's why the image did not show correctly.

    Thank you for your help!

    I will have a look at CGI::Simple. Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://159768]
Approved by mce
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-24 19:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found