Loading ...
Sorry, an error occurred while loading the content.

And now in the filesystem

Expand Messages
  • kjhseka
    Hello, 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
    Message 1 of 1 , Jul 2 3:58 PM
    • 0 Attachment
      Hello,
      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");
      my $img_buffer='';

      $name =~ s/^\s+//;
      $name =~ s/\s+$//;

      # Also work with while (<$image>); The upload("image") is not
      really required.
      # This is just an alternative to $image = param("image").
      while(<$img_data>)
      {
      $img_buffer .= $_;
      }

      open(IMAGEFILE, ">images/$name.jpg");
      print IMAGEFILE $img_buffer;
      close(IMAGEFILE);


      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
      receive:
      "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
      Alph
    Your message has been successfully submitted and would be delivered to recipients shortly.