Ver Mensaje Individual
  #3 (permalink)  
Antiguo 17/06/2011, 04:25
Avatar de kanalejana
kanalejana
 
Fecha de Ingreso: agosto-2009
Mensajes: 23
Antigüedad: 14 años, 8 meses
Puntos: 1
Respuesta: Un poco de luz con Uploadify

Al final si que lo he conseguido hacer \o/ asi me ha quedado el codigo

Código PHP:
/*COMPROBACION SI SE HA SUBIDO UNA FOTO*/
$ruta="uploadify/uploads/".$idf."/";
if(
$dh opendir($ruta)){
    echo 
"<br>DH TRUE: ".$dh;
    while ((
$file readdir($dh))){
        if(
$file!="."&&$file!=".."&&$file!="Thumbs.db"){
            echo 
"<br>FICHERO: ".$file;
            
$noimagen="";
            break;
        }else{
            
$noimagen="error";
            }
        }

Código Javascript:
Ver original
  1. $('#file_upload').uploadify({
  2.             'uploader'    : 'uploadify/uploadify.swf',
  3.             'script'      : 'uploadify/uploadify.php',
  4.             'multi'       : true,
  5.             'auto'        : true,
  6.             'queueSizeLimit' : 10,
  7.         'removeCompleted' : false,
  8.             'sizeLimit'   : '1048576',
  9.             'buttonText': 'Sube tus fotos',
  10.             'cancelImg'   : 'uploadify/cancel.png',
  11.             'folder'      : 'uploadify/uploads/<?echo $idf?>/',
  12.             'fileExt'     : '*.jpg',
  13.             'fileDesc'    : 'Sube tus fotos (.jpg)',
  14.             'onComplete'  : function(event, queueID, fileObj, response, data) {
  15.                     $("#destino").load("recibe.php", {
  16.                         fichero: fileObj.name,
  17.                         pos: data.fileCount,
  18.                         id: <?echo $idf?>
  19.                     })
  20.             }/*on complete*/
  21.         });

Código HTML:
Ver original
  1.     <div style='color:white;'id='destino'></div>
  2. </body>

RECIBE.PHP

Código PHP:
<script>alert('<?echo $_POST['pos'];?>: <img src="uploadify/uploads/<?echo $_POST['id'];?>/<?echo $_POST['fichero'];?>"/>');</script>

<?
$imagen
=$_POST['fichero'];
$path='uploadify/uploads/'.$_POST['id'];
    
$original imagecreatefromjpeg($path.'/'.$imagen);
    
$ancho imagesx($original);
    
$alto imagesy($original);
    if (
$ancho $alto) {
        
$thumb imagecreatetruecolor(14590);
        
imagecopyresampled($thumb$original000014590$ancho$alto);
    } else {
        
$thumb imagecreatetruecolor(145200);
        
imagecopyresampled($thumb$original0000145200$ancho$alto);
    }
    
$tipo substr($imagen, -4);
    
$th $path .'/'$_POST['id'] . '-' $_POST['pos'] . '-th' .  $tipo;
    
imagejpeg($thumb$th90); // 90 es la calidad de compresión
    
rename($path .'/'$imagen$path .'/'.$_POST['id']. '-' $_POST['pos'] . $tipo);
?>
<?
echo $_POST['pos'];?>: <img src="<?echo $th;?>"/>
Espero que a alguien le pueda servir de ayuda