Announcement

Collapse
No announcement yet.

Loading Picture

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Conscience
    replied
    so what I said was correct coz you are in essence simply storing as a txt file

    Leave a comment:


  • Mark Hensler
    replied
    Remember... everything boils down to 1's and 0's.

    Leave a comment:


  • Mark Hensler
    replied
    Yes, you can save images into a mySQL database.
    Code:
    // Read the image file into $img
    $fp = @fopen ($graphic, "r");
    if ($fp){
        $photoBlob = fread ($fp, filesize($graphic));
        $img = str_replace ("'", "''", $img);
        $img = str_replace ("\\", "\\\\", $img);
        $img = str_replace ("\"", "\\\"", $img);
        $img = str_replace ("\0", "\\\0", $img);
        fclose ($fp);
    }
    // Now save $img into a DB field (most likely a blob data type)
    To print the image, you need a seperate file. Such as img_print.php
    Call it like this:
    Code:
    <img src="img_print.php?id=123">
    img_print.php looks like this:
    PHP Code:
    // Read image from DB
    $query "SELECT image_field_name FROM table_name WHERE ID=$id";
    $result mysql_query($query);
    if (!
    $result) {
        echo 
    "\n<!--QUERY ERROR:" mysql_error() . "-->\n";
        echo 
    "\n<!--QUERY:$query-->\n";
    }
    $tmp mysql_fetch_row($result);

    // Now pring the image
    echo $tmp[0]; 

    Leave a comment:


  • Conscience
    replied
    as far as i know mySQL only lets you save txt to it

    Leave a comment:


  • csoonyen
    started a topic Loading Picture

    Loading Picture

    Hey all,

    I am quite new to PHP and MySQL. Just wondering, can I save all types of pictures files into my MySQL DB? And how do I load it? Can anyone lead me in coding. Please help! Thanks
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X