Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/05/2003, 13:56
safe
 
Fecha de Ingreso: enero-2003
Ubicación: Córdoba, Argentina
Mensajes: 1.047
Antigüedad: 21 años, 3 meses
Puntos: 10
Problema creando Galeria de Fotos

Hola muchachos del web, tuve la idea de crear un codigo sencillo que me hiciera una galeria de imagenes de una carpeta con imagenes. Les comento que mis conocimientos sobre PHP son bastante escasos pero luego de una larga investigacion por forosdelweb y otros sitios llegue a un codigo que me parece no esta tan lejos de lo que necesito.
Primero les comento cual es el problema que me da y luego les paso el codigo....

una vez que subi el archivo y un par de fotos de prueba, el archivo se ejecuto creo la carpeta "thumbs" y creo las miniaturas, pero el problema es que a ambas les asigno un valor que hace que yo no las pueda leer y ni siquiera borrar. Intente cambiarle los permisos desde el administrador no hay forma no se cambia nada.
Pero el problema no quedo ahi, despues ya no me creo mas la carpeta ni las miniaturas y me devuelve el siguiente error:

Warning: imagejpeg: unable to open 'thumbs/tn_PIC00057.jpg' for writing in /var/www/www/mantox/html/flaco/index.php on line 33

¿Que tengo mal en el codigo? ¿me recomiendan alguna otra forma mas sencilla de hacerlo?

Desde ya muchas gracias

<? function createthumb($name,$filename,$new_w,$new_h){
global $gd2;
$system=explode(".",$name);
if (preg_match("/jpg|jpeg/",$system[1])){
$src_img=imagecreatefromjpeg($name);
}
if (preg_match("/png/",$system[1])){
$src_img=imagecreatefrompng($name);
}
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x > $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y) {
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) {
$thumb_w=$new_w;
$thumb_h=$new_h;
}

if ($gd2==""){
$dst_img=ImageCreate($thumb_w,$thumb_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_ w,$thumb_h,$old_x,$old_y);
}else{
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thum b_w,$thumb_h,$old_x,$old_y);
}

imagejpeg($dst_img,$filename);
imagedestroy($dst_img);
imagedestroy($src_img);
}
?>
<html>
<head>
<body leftmargin="0" topmargin="0">
<table height="2" border="0" cellpadding="0" cellspacing="0">
<tr><td>GALERIA:</td>

<?php


$dir = opendir('.');

while(false !== ($file = readdir($dir))) {
if ($file != "." AND $file != ".." AND $file != "index.php")
{
if(is_dir($file)) {
echo "<td width=3 align=center><font size=1 color=#000000>&nbsp;";
echo "<a href=$file>";
echo "$file"."</a>";
echo "</font></td>\n";
}
else {
echo createthumb($file,"thumbs/tn_".$file,100,100);
$mostrar = "<img src='thumbs/tn_".$file."'>";
echo $mostrar;
}
}
}
closedir($dir);

?>

</tr>
</table>
</form>
</div>
</body>
</html>