ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-spanish
php-spanish
[PHP-ES] Im?genes y bases de datos
by Nestea1974 other posts by this author
Oct 15 2009 12:49PM messages near this date
Re: [PHP-ES] raro resultado | Re: [PHP-ES] Imágenes y bases de datos
Hola, me gustaría saber como recuperar una imagen de una base de datos
y mostrarla... Llevo 3 tardes machacándome la cabeza y algo pasa en la
recuperación de la imagen del campo blob. Si no hay base de datos de
por medio funciona... el código es el siguiente, muchas muchas
muchas gracias de antemano:
<?php
	if (is_uploaded_file($_FILES['foto1']['tmp_name']) &&
$_FILES['foto1']['size'] < 5120000 && $_FILES['foto1']['type'] ==
'image/jpeg') { move_uploaded_file($_FILES['foto1']['tmp_name'],
"../proyecto/subidas/".$_FILES['foto1']['name']); $image = new
Imagick("../proyecto/subidas/".$_FILES['foto1']['name']);
$image-> adaptiveResizeImage(180,120); $imagenSerializada =
serialize($image); $mysqli = new mysqli ('localhost', 'root', '',
'proyecto') or die (mysqli_connect_error()); $query = "INSERT INTO
fotop (fotop) VALUES ('$imagenSerializada');"; $mysqli-> query($query)
or die (mysqli_error()); 
		$result = $mysqli-> query("SELECT `fotop`.`fotop`,
`fotop`.`fotopid` FROM fotop WHERE fotopid = '0';") or die
(mysqli_error()); while ($fila = $result-> fetch_object()) { $imagen =
unserialize($fila-> fotop); }
		$result-> close();
		$mysqli-> close();
		header('Content-type: image/jpeg');
		echo "$imagen";
	}
	//...
?> 

--
PHP Spanish Localization Talk Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thread:
Nestea1974
Gerardo Benitez
Denyl Meneses
Martin Scotta

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved