Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- //script para guardar imagenes desde una base de datos con contenido BLOB
- $dbhost = 'localhost';
- $dbname = 'nombredelabase';
- $dbusername = "usuario";
- $dbuserpass = 'contraseña';
- $demo1 = mysqli_connect($dbhost, $dbusername, $dbuserpass, 'credencial') or trigger_error(mysql_error(),E_USER_ERROR);
- $consulta = mysqli_query($demo1, "SELECT * FROM imagenes");
- while ($dato = mysqli_fetch_array($consulta, MYSQLI_ASSOC))
- {
- $foto = $dato['Foto'];
- $id = $dato['idPersona'];
- //extrae la foto del blob
- $source_img = imagecreatefromstring($foto);
- $file = 'imagenes/'. $id . '_foto.jpg';
- $imageSave = imagejpeg($source_img, $file, 90);
- imagedestroy($source_img);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement