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

Uploading issues

Expand Messages
  • kjhseka
    Hello, 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
    Message 1 of 1 , Jul 2, 2005
    • 0 Attachment
      Hello,
      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);


      If I modify the script and try to upload the image in the database as
      blob type rather than in the filesystem everything works and I can
      see the image in my browser if I serve it with an appropiate
      function. But if I run the code as is, the image will be uploaded...
      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.