perlquestion
zuluwarhelmet
I have the following code to upload a file to a webserver:
<code>
#!/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"};
</code>
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
<code>
<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" /></code> in IE and <code>
<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" /></code> 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?