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

Re: Image uploading and storing issues

Expand Messages
  • Damien Carbery
    ... Image::Magick is not a core perl module so your hosting service may not have it. If they have ImageMagick installed you might be able to use the convert
    Message 1 of 4 , Jun 27, 2005
    • 0 Attachment
      --- In perl-beginner@yahoogroups.com, "kjhseka" <kjhseka@h...> wrote:
      > Hello,
      > I have a script with several problems on it. The script is taken
      > from MySql and Perl from the Web by Paul Dubois.
      >
      > First of all, I run it into Windows XP system, with Apache
      > server and MySql. I use IE 6 to test it. The script should
      > upload an image and store it in the database. I try the script
      > locally.
      >
      > But...
      >
      > 1) If I try to upload an image, actually no data is stored in the
      > database! The database is defined as follow:
      >
      > CREATE TABLE image (name VARCHAR(60) NOT NULL, UNIQUE(name), image
      > BLOB NOT NULL,
      > thumbnail BLOB NOT NULL, mime_type VARCHAR(20) NOT NULL);
      >
      > 2) $image variable in my $image = param("image"); should store the
      > binary data of the
      > image, but it actually only store the path and filename! Is that
      > normal? Why the variable does not store the binary data?
      >
      > Another thing... The Image::Magick module does no longer exist! Is
      > never installed in
      > most web servers and hosting services and is very difficult to get
      > it. What kind of module is used right now to process images?
      >
      > Here's the script, the main problem is that no data is stored in the
      > database, there
      > is surely some error, but I'm unable to locate it. Or perhaps in
      > Windows image uploading works differently?
      >
      >
      > #! d:/perl/bin/perl.exe
      > # upload_image.pl - upload images for e-greeting card application
      > snip the code
      >
      > Thanks for any help.
      >
      > Alph

      Image::Magick is not a core perl module so your hosting service may
      not have it. If they have ImageMagick installed you might be able to
      use the 'convert' executable directly. I have a script that creates
      thumbnails with 'convert'.

      According to the CGI.pm documentation
      http://search.cpan.org/~lds/CGI.pm-3.10/CGI.pm#CREATING_A_FILE_UPLOAD_FIELD
      you should use the 'upload' function to access the contents of the
      uploaded file.

      You say you expect $image to have the image contents. From looking at
      the code I would have expected $full to be used (returned by
      read_image_file).
    • kjhseka
      Hello and thanks for the reply. If Image::Magick is not a core perl module, which is the core and standard perl module that everybody use to work with images?
      Message 2 of 4 , Jun 27, 2005
      • 0 Attachment
        Hello and thanks for the reply.

        If Image::Magick is not a core perl module, which is the core and
        standard perl module that everybody use to work with images? I
        looking for something like PHP image manupulation functions,
        something available in any web server.

        And, more important: I understand that I can use upload function...
        But I don't understand why Paul Dubois use:

        my $image = param("image");

        To retrieive the image and

        $dbh->do("REPLACE INTO image (name, image, thumbnail,
        mime_type), VALUES(?,?,?,?)", undef, $name, $image, $thumb,
        $mime_type);

        To store it in the database without using any upload function or
        similar stuff. param("image"); should be perfectly sufficient, so
        perhaps I should understand in great detail how uploading works.

        I only know this: after the user upload the file, the data is stored
        in a temporary file on server. The script should retrieive it, but
        why param("image") in this, case would not be sufficient?

        Thanks
        Alph

        --- In perl-beginner@yahoogroups.com, "Damien Carbery"
        <daymobrew@y...> wrote:
        > --- In perl-beginner@yahoogroups.com, "kjhseka" <kjhseka@h...>
        wrote:
        > > Hello,
        > > I have a script with several problems on it. The script is taken
        > > from MySql and Perl from the Web by Paul Dubois.
        > >
        > > First of all, I run it into Windows XP system, with Apache
        > > server and MySql. I use IE 6 to test it. The script should
        > > upload an image and store it in the database. I try the script
        > > locally.
        > >
        > > But...
        > >
        > > 1) If I try to upload an image, actually no data is stored in the
        > > database! The database is defined as follow:
        > >
        > > CREATE TABLE image (name VARCHAR(60) NOT NULL, UNIQUE(name),
        image
        > > BLOB NOT NULL,
        > > thumbnail BLOB NOT NULL, mime_type VARCHAR(20) NOT NULL);
        > >
        > > 2) $image variable in my $image = param("image"); should store
        the
        > > binary data of the
        > > image, but it actually only store the path and filename! Is that
        > > normal? Why the variable does not store the binary data?
        > >
        > > Another thing... The Image::Magick module does no longer exist!
        Is
        > > never installed in
        > > most web servers and hosting services and is very difficult to
        get
        > > it. What kind of module is used right now to process images?
        > >
        > > Here's the script, the main problem is that no data is stored in
        the
        > > database, there
        > > is surely some error, but I'm unable to locate it. Or perhaps in
        > > Windows image uploading works differently?
        > >
        > >
        > > #! d:/perl/bin/perl.exe
        > > # upload_image.pl - upload images for e-greeting card application
        > > snip the code
        > >
        > > Thanks for any help.
        > >
        > > Alph
        >
        > Image::Magick is not a core perl module so your hosting service may
        > not have it. If they have ImageMagick installed you might be able to
        > use the 'convert' executable directly. I have a script that creates
        > thumbnails with 'convert'.
        >
        > According to the CGI.pm documentation
        > http://search.cpan.org/~lds/CGI.pm-
        3.10/CGI.pm#CREATING_A_FILE_UPLOAD_FIELD
        > you should use the 'upload' function to access the contents of the
        > uploaded file.
        >
        > You say you expect $image to have the image contents. From looking
        at
        > the code I would have expected $full to be used (returned by
        > read_image_file).
      • merlyn@stonehenge.com
        ... kjhseka If Image::Magick is not a core perl module, which is the core and kjhseka standard perl module that everybody use to work with images? There
        Message 3 of 4 , Jun 27, 2005
        • 0 Attachment
          >>>>> "kjhseka" == kjhseka <kjhseka@...> writes:

          kjhseka> If Image::Magick is not a core perl module, which is the core and
          kjhseka> standard perl module that everybody use to work with images?

          There isn't one. Most people use GD or Image::Magick or Imager.

          The CPAN is your friend. Learn to use the CPAN.

          --
          Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
          <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
          Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
          See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
        Your message has been successfully submitted and would be delivered to recipients shortly.