Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Why doesn't file upload work under NT?

by Anonymous Monk
on May 16, 2000 at 00:25 UTC ( [id://11737]=perlquestion: print w/replies, xml ) Need Help??

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

I have a script to read a file from an HTML upload field. The files are .pdf's and using the same script, the .pdf does not get uploaded right on NT but does on a Linux server. When trying to open the uploaded file, Acrobat gives "unrecognized token" and then "there were several parsing errors", and doesn't open it. Works great on Linux. ANybody have an idea why? Code below.
undef $BytesRead; undef $Buffer; while ($Bytes = read($File_Handle,$Buffer,1024)) { $BytesRead += $Bytes; print OUTFILE $Buffer; } push(@Files_Written, "$SAVE_DIRECTORY\/$Filename"); $TOTAL_BYTES += $BytesRead; $Confirmation{$File_Handle} = $BytesRead; close($File_Handle); close(OUTFILE); chmod (0666, "$SAVE_DIRECTORY\/$Filename");
Thanks! Str

Replies are listed 'Best First'.
Re: Why doesn't file upload work under NT?
by guice (Scribe) on May 16, 2000 at 01:27 UTC
    Hum.. Sounds like possibly Line Breaks as well. After all .pdf files are just text files. Although if there are some images in there, that may cause in issue. Make sure that you are setting your like breaks correctly as well. On the Windows OS its: \r\n and on Unix/Linux its: \n. It's \r on Macintosh systems incause you're curious :)
    If there are no images in the PDF file, then you are fine. If there are, then make sure you use binmode. It sounds like binmode isn't an issue cause it works on your linux system. The next thing is to play with your line breaks. Set $\ to "\r\n" on the windows system and "\n" on the linux system (Perl defaults to "\n"). Better yet, take a look at the file on the WinNT box. You may have \n in there, so you just need to convert "\n" to "\r\n" to get it working.

    A couple things for ya to try out ;)

    -- philip
    We put the 'K' in kwality!

      I have the same problem on win32! No cigar as yet
Re: Why doesn't file upload work under NT?
by btrott (Parson) on May 16, 2000 at 00:36 UTC
    Sounds like you might need binmode:
    binmode $File_Handle; binmode OUTFILE;
    Do this before you read from $File_Handle or write to OUTFILE.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-03-28 13:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found