Re: campos blob

From: Date: Thu, 18 Sep 2008 15:23:33 +0000
Subject: Re: campos blob
References: 1 2 3 4  Groups: php.general.es 
Request: Send a blank email to general-es+get-63167@lists.php.net to get a copy of this message
hola a todosles copio/pego lo que he hecho -es un ejemplo no optimizado pero funcional- por si a alguien le puede servir en algun momento muchas gracias a todos!!! <?php // function to encode the image....returns the image as base64 encoded string //function encode_img($img){ //$fd = fopen ($img, 'rb'); //$size=filesize ($img); //$cont = fread ($fd, $size); //fclose ($fd); //return $encimg = base64_encode($cont); //} // function to save the image function display_img($encimg,$name,$destino){ // //echo $encimg=base64_decode($encimg); $gestor = fopen($destino.$name, "w"); // fwrite($gestor, $encimg); // fclose($gestor); } // use like //$encimg=encode_img('1.jpg'); // to encode the image //$type='jpg'; //$name='pepe3'; //display_img($encimg,$type,$name); // to show the image // require_once("common.php"); // $sql = "SELECT picture,idProduct,pictureType FROM product"; // $result = mysql_query($sql, $_SERVER['connection']) or die(mysql_error()); // while ($row = mysql_fetch_array($result)){ // $encimg=''; $name=''; $destino=''; // $encimg=$row[0]; if(!is_null($encimg)){ // $idProduct=trim($row[1]); // $mimetype=trim($row[2]); $type=explode('/',$mimetype); if($type[1]=="x-png"){ $type="png"; }else{ $type=$type[1]; } // $name="$idProduct.$type"; // //$destino='./pepe/'; $destino='./'; // display_img($encimg,$name,$destino); // to show the image }else{// //SI ES NULA, O SEA QUE NO TENGO NINGUNA IMAGEN, ENTONCES DEBERIA DE CREAR UNA IMAGEN EN BLANCO QUE DIGA "IMAGEN NO DISPONIBLE" O ALGO ASI .... } } echo '<h1>script Finalizado OK </h1>'; mysql_free_result($result); ?> El 17 de septiembre de 2008 13:04, Carlos Medina <info@simply-networks.de>escribió: > Roberto Barreiro schrieb: > >> hola a todos >> muchas gracias por contestar, ha costado un poco pero ya esta resuelto >> salu2 >> >> Como lo resolviste (creo que nos interesa a todos ;-) > > Salu2 > > Carlos > > -- > PHP Spanish Localization Talk Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general.es (#63167) next »