I definitively solved the previous problem, now I can perfectly
upload an image in the database and see it in my browser with a
serving function. Now, I try to upload an image in the filesystem
rather than in a database, using the following code (note I run Perl
on Windows XP with Apache server):
my $name = param("name");
my $image = param("image");
my $img_data = upload("image");
$name =~ s/^\s+//;
$name =~ s/\s+$//;
# Also work with while (<$image>); The upload("image") is not
# This is just an alternative to $image = param("image").
$img_buffer .= $_;
print IMAGEFILE $img_buffer;
Everything work fine, the image is uploaded, the filename created,
but I cannot see it in my Windows Picture and Fax Viewer. If I try to
open this image with Adobe Phptoshop, I receive the following error:
"Could not open "path\image.jpg" because invalid DQT JPEG QTable
number is found (it must be 4)"
I also tried to open it with another graphical software, but I
"Unknown file format" error.
Obviously, there is something incorrect in my code. Perhaps there is
some CR/LF corruption and the image is not properly parsed, perhaps I
should to escape $_ before fill $image_buffer, perhaps I must specify
some mime-type in a way that I ignore...
Some one can give my any idea?
Thanks a lot