Jump to content

sputnik577

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Posts posted by sputnik577

  1. How can i load a picture from a mySQL database using php. The picture is uploaded in a table and then dynamically loaded to a php page. It's attribute in the database table is longblob.
    [code]while(list($name, $type, $size, $path) = mysql_fetch_array($imgResult))
      {
       
        $im = open_image($path);

    if ($im === false) {
            die ('Unable to open image');
    }

    header ('Content-Type: image/jpeg');
    imagejpeg($path);
    echo 'Opened image';

    function open_image($path) {
            # JPEG:
            $im = @imagecreatefromjpeg($path);
            if ($im !== false) { return $im; }

            # GIF:
            $im = @imagecreatefromgif($path);
            if ($im !== false) { return $im; }

            # PNG:
            $im = @imagecreatefrompng($path);
            if ($im !== false) { return $im; }

            # GD File:
            $im = @imagecreatefromgd($path);
            if ($im !== false) { return $im; }

            # GD2 File:
            $im = @imagecreatefromgd2($path);
            if ($im !== false) { return $im; }

            # WBMP:
            $im = @imagecreatefromwbmp($path);
            if ($im !== false) { return $im; }

            # XBM:
            $im = @imagecreatefromxbm($path);
            if ($im !== false) { return $im; }

            # XPM:
            $im = @imagecreatefromxpm($path);
            if ($im !== false) { return $im; }

            # Try and load from string:
            $im = @imagecreatefromstring(file_get_contents($path));
            if ($im !== false) { return $im; }

            return false;
    }[/code]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.