Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2002
    Location
    singapore
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    save image in mysql database

    hai...
    can i store an image inside mysql database?
    if can, please show me..
    tanks

  • #2
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Yes You Can!

    Take look :

    sub addNews {
    my $self = shift;
    my $file = param('new_pic'); #this is a Image File

    undef $file_cont;
    binmode $file;
    binmode $file_cont;
    while (<$file>){
    $file_cont .= $_;
    }
    my $sql = "INSERT INTO sys_news
    SET Image= ". $self->{SQL}->quote($file_cont).", CreateDate=NOW()";
    $self->{SQL}->do($sql); # this means $dbh->do($sql);
    }

  • #3
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    You can save a picture inside a DB but as several threads here suggest its usually better to save the PATH to the image file instead. Try using the search function to find some of those old threads.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #4
    Regular Coder
    Join Date
    Jul 2009
    Posts
    143
    Thanks
    0
    Thanked 0 Times in 0 Posts
    how do you save the PATH? I've created a field for images in my form but, I can't cut and paste the file name to include. Any suggestions? Thanks

  • #5
    New to the CF scene
    Join Date
    Dec 2010
    Location
    Denmark
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use input field of type file. The file is sent to the server as $_FILES. var dump this and you'll be a long way.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •