http://qs1969.pair.com?node_id=700594

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

I have the following code to upload a file to a webserver:
#!/usr/bin/perl -w use CGI qw (:standard); use CGI::Carp qw( fatalsToBrowser ); $CGI::DISABLE_UPLOADS=0; print header; $fh = upload('photo'); print h1("$fh"); open(PIC,'>>../pic.jpg') || die "Cannot open file: $!"; binmode(PIC) || die "Cannot binmode: $!"; while (<$fh>) { print $_; } close(PIC); print br,Dump,br; print br, img{src=>"../pic.jpg"};
Now I know it won't actually print to the file as it is, I changed the print statement so it should print straight to the browser. However, all it returns is
<h1>E:\309856393_0b02b023d6.jpg</h1><br /><ul> <li><strong>photo</strong></li> <ul> <li>E:\309856393_0b02b023d6.jpg</li> </ul> <li><strong>submit</strong></li> <ul> <li>GO FOR IT</li> </ul> </ul><br /><br /><img src="../pic.jpg" />
in IE and
<h1>309856393_0b02b023d6.jpg</h1><br /><ul> <li><strong>photo</strong></li> <ul> <li>309856393_0b02b023d6.jpg</li> </ul> <li><strong>submit</strong></li> <ul> <li>GO FOR IT</li> </ul> </ul><br /><br /><img src="../pic.jpg" />
in Firefox. It does this whether I do <$fh> or read($fh,$buffer,1024). Is there something I'm missing or do I need to do something else to make it read the file?