I'm writing a CGI-Script that's supposed to do something very simple that I've done a few times before: Upload an image and save it on the webserver. Here's what I got:
sub handle_image
{
my $id = shift or die "Internal Error\n";
my $image = param ('image');
my $filename = '';
if ($image)
{
$filename = '/images/' . $id . '.jpg';
open (IMAGE, '> ..' . $filename);
while (my $bytestoread = read ($image, my $buffer, 102
+4))
{
print IMAGE $buffer;
}
close IMAGE;
}
elsif (-e '../images/' . $id . '.jpg')
{
$filename = '/images/' . $id . '.jpg';
}
return $filename;
}
As you see the routine checks for data to save or, if no data available, for an existing image and returns the filename.
The odd thing is, that this script works fine on my local workstation, but not on the webserver. $image holds the filename of the image, but the filehandle (<$image>) is empty. And yes, I'm using
enctype="multipart/form-data" and the directory is writeable for the webserver. It creates a new but empty file.. I've checked all nodes about CGI.pm and file uploading but I couldn't find an answer.
Are there any differences between different versions of CGI.pm or perl that might cause that problem?
Regards,
octopus
--
GED/CC d-- s:- a--- C++(+++) UL+++ P++++$ L++>++++ E--- W+++@ N o? K? w-- O- M-(+) V? !PS !PE !Y PGP+(++) t-- 5 X+ R+(+++) tv+(++) b++@ DI+() D+ G++ e->+++ h!++ r+(++) y+