Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 25th, 2000, 02:02 AM
chinnavi
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

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



Reply With Quote
  #2  
Old June 26th, 2000, 02:36 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan
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..."

Reply With Quote
  #3  
Old June 27th, 2000, 01:55 AM
dwarf dwarf is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 300 dwarf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Shiju,

Shouldn't that be:

$giffile .= $_;



[This message has been edited by dwarf (edited June 27, 2000).]

Reply With Quote
  #4  
Old June 27th, 2000, 09:39 AM
Imo Imo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 1999
Posts: 33 Imo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
What about:

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

[1] you might want a binmode(GIF) there? Not sure.

Reply With Quote
  #5  
Old June 27th, 2000, 11:04 AM
vpopper's Avatar
vpopper vpopper is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Location: Southern California
Posts: 73 vpopper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 56 m 9 sec
Reputation Power: 13
<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).]

Reply With Quote
  #6  
Old June 29th, 2000, 02:33 AM
chinnavi
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Help in Image insertion in Mysql

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap