#1
  1. No Profile Picture
    chinnavi
    Guest
    Devshed Newbie (0 - 499 posts)

    I have one problem in storing a Gif file in Mysql thro' PERL...
    I connected Mysql thro PERL DBI.
    I want to read full image into a variable.
    i used this code

    open(GIF,"a.gif");
    $giffile = <GIF>;

    close(GIF);

    but the problem is it reads only "one line" of GIF file ....
    Please help me in getting full gif image.

    vijay


  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    vijay,

    just try with a loop to read till end of the file.

    open(GIF,"a.gif");
    while(<GIF> ){
    $giffile = <GIF>;
    }
    close(GIF);


    just give a try...



    ------------------
    SR -
    shiju.dreamcenter.net

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    Shiju,

    Shouldn't that be:

    $giffile .= $_;



    [This message has been edited by dwarf (edited June 27, 2000).]
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 1999
    Posts
    33
    Rep Power
    16
    What about:

    open(GIF,"a.gif") or die;
    [1]
    @giffile = <GIF>;
    close(GIF);

    [1] you might want a binmode(GIF) there? Not sure.
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Southern California
    Posts
    73
    Rep Power
    15
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by chinnavi:

    I want to read full image into a variable.
    i used this code
    open(GIF,"a.gif");
    $giffile = <GIF>;
    close(GIF);

    but the problem is it reads only "one line" of GIF file ....
    [/quote]

    Try this:

    $path = '/path/to/a.gif';
    $len = -s $path;

    open FH, $path or die "cannot open $path: $!n";
    $bytesread = read(FH,$buffer,$len);

    die "read errorn" unless $bytesread == $len;
    close FH;

    now you can insert $buffer into your table...


    [This message has been edited by vpopper (edited June 27, 2000).]
  10. #6
  11. No Profile Picture
    chinnavi
    Guest
    Devshed Newbie (0 - 499 posts)

    Thanks for all .
    Now it works fine and well .
    Is there any way to hide the images from saving ..
    I saw in one site that we cant save any images by right clicking on the image ..

    vijay

IMN logo majestic logo threadwatch logo seochat tools logo