Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/12/2008, 17:40
Avatar de gabyweb
gabyweb
 
Fecha de Ingreso: enero-2002
Ubicación: Lima
Mensajes: 364
Antigüedad: 23 años, 1 mes
Puntos: 0
Pregunta Cómo muestro un icono al lado de cada foto?

Hola amig@s:

Tengo estos archivos:

"multiupload.html"
Código:
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>Display thumbnails example</title>
 <link rel="stylesheet" href="styles.css"/>
</head>
<body>
<h3>Display thumbnails example:</h3>
<br/>
<table>
 <tr>
  <td align="center">
   <div id="MultiPowUpload_holder">You need at least 9 version of Flash player. Download last version 
    <a target="_blank" href="http://www.adobe.com/shockwave/downl...ates/">here</a>!
   </div>
<!-- SWFObject home page: http://code.google.com/p/swfobject/ -->
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
 var params = {  
  BGColor: "#F8F6E6"
 };
 
 var attributes = {  
  id: "MultiPowUpload",  
  name: "MultiPowUpload"
 };
 
 var flashvars = {
   uploadUrl: "FileProcessingScripts/PHP/createthumbnail.php",
   useExternalInterface: "Yes",
   fileTypes: "JPEG images|*.jpg\;*.jpeg"
 };
 
 swfobject.embedSWF("ElementITMultiPowUpload2.swf", "MultiPowUpload_holder", "450", "350", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
</script>
  </td>
 </tr>
</table>
<script language="JavaScript">
 //MultiPowUpload_onComplete. Invoked when the upload or download of single file operation has successfully completed
 function MultiPowUpload_onComplete(type, index, serverResponse)
 {
  addThumbnail(serverResponse);
 }
 function addThumbnail(source)
 {
  var Img = document.createElement("img");
  Img.style.margin = "5px";
  if(source != "no_image")
   Img.src = source;
  else
   Img.src = "Images/elementitlogo.gif";
  //document.getElementById("thumbnails").innerHTML = "<a href=\"javascript:alert('Portada de Album')\"><img src=\"icon_photoalbum.gif\" border=\"0\"/></a>";
  document.getElementById("thumbnails").appendChild(Img);
  
 }
</script>
<div id="thumbnails"></div>
</body>
</html>
y este script php: "createthumbnail.php"
Código PHP:
<?php
 
/* Note: GD PHP Extension should be installed on server.  */
//trying restore browser cookie
if(isset($_POST['MultiPowUpload_browserCookie']))
{
 
$cookies split(";"$_POST['MultiPowUpload_browserCookie']);
 foreach(
$cookies as $value)
 {
  
$namevalcookies split("="$value); 
  
$browsercookie[trim($namevalcookies[0])] =  trim($namevalcookies[1]);
 }
 
$_COOKIE $browsercookie;
}
//restore session if possible
if(isset($browsercookie) && isset($browsercookie['PHPSESSID']))

 
session_id($browsercookie['PHPSESSID']);
 
session_start();
}
$uploaddir dirname($_SERVER['SCRIPT_FILENAME'])."/UploadedFiles/";
if(
count($_FILES) > 0)
{
 foreach(
$_FILES as $name=>$arrfile)
 {
  
$filename basename($arrfile['name']);
  
$uploadfile $uploaddir $filename;
//echo $filename." - ".$uploadfile."<br/>";
  
if (move_uploaded_file($arrfile['tmp_name'], $uploadfile))
  {
   
$image = @imagecreatefromjpeg($uploadfile);
   if (
$image)
   {
    
$width imageSX($image);
    
$height imageSY($image);
    
// Build the thumbnail
    
$target_width 100;
    
$target_height 100;
    
$target_ratio $target_width $target_height;
    
$image_ratio $width $height;
    if (
$target_ratio $image_ratio) {
     
$new_height $target_height;
     
$new_width $image_ratio $target_height;
    } else {
     
$new_height $target_width $image_ratio;
     
$new_width $target_width;
    }
    if (
$new_height $target_height) {
     
$new_height $target_height;
    }
    if (
$new_width $target_width) {
     
$new_height $target_width;
    }
    
$new_img ImageCreateTrueColor($target_width$target_height);
    if(!@
imagefilledrectangle($new_img00$target_width-1$target_height-10xFFFFFF))
    {
     echo 
"no_image";
     exit(
0);
        }
    if(!@
imagecopyresampled($new_img$image, ($target_width-$new_width)/2, ($target_height-$new_height)/200$new_width$new_height$width$height))
    {
     echo 
"no_image";
     exit(
0);
        }
    
$thumbnail =  md5($uploadfile rand()*100000).".jpg";
    
imagejpeg($new_img$uploaddir.$thumbnail);
                echo 
dirname($_SERVER['PHP_SELF'])."/UploadedFiles/".$thumbnail;
   }
   else
   {
    echo 
"no_image";
    exit(
0);
      }
  }
  else
  {
   echo 
"no_image";
   exit(
0);
    }
    
 }
}
?>
Funciona correctamente, pero lo que quisiera hacer es colocar un icono con un enlace al lado de cada imagen mostrada. Lo he intentado con la linea comentada en el archivo html, antes del appendchild(Img) y no me sale. Ayuda por favor.

Gracias
__________________
Gaby :adios: