Ver Mensaje Individual
  #6 (permalink)  
Antiguo 09/09/2010, 14:08
Avatar de xamilo
xamilo
 
Fecha de Ingreso: febrero-2010
Mensajes: 120
Antigüedad: 14 años, 2 meses
Puntos: 1
Respuesta: guardar imagen en una variable

ya intento y no me resulto...
tengo esto para cargar las fotos y mostralas tal cual en sus dimenciones originales
Código PHP:
Ver original
  1. <?php
  2. if($_REQUEST['enviado'] == 1){
  3. $ruta = "./imagenes/" . $_FILES['archivo']['name'];
  4. copy($_FILES['archivo']['tmp_name'], $ruta);
  5. echo "<script>alert('El archivo subio correctamente');</script>";
  6. }
  7. ?>
  8. <html>
  9. <head>
  10. <title>Subir imagenes y mostrarlas</title>
  11. <script>
  12. <!--
  13. function validar(){
  14. if(document.getElementById('archivo').value == ''){
  15. alert("Debe seleccionar un archivo";
  16. return false;
  17. }
  18. }
  19. -->
  20. </script>
  21. </head>
  22. <body>
  23. <form name="formulario" enctype="multipart/form-data" method="POST" action="" onsubmit="return validar(this)">
  24. <table>
  25. <tr>
  26. <td colspan="2" bgcolor="Olive"><strong>Uploads de imagenes</strong></td>
  27. </tr>
  28. <tr>
  29. <td>Imagen</td>
  30. <td><input type="file" name="archivo" id="archivo"><input type="hidden" name="enviado" value="1"></td>
  31. </tr>
  32. <tr>
  33. <td colspan="2" align="right"><input type="submit" value="Enviar"></td>
  34. </tr>  
  35. </table>
  36. </form>
  37. <table>
  38. <tr>
  39. <td align="left"><strong>Imagenes</strong></td>
  40. </tr>
  41. <tr>
  42. <td>
  43. <?
  44. $dir=opendir("./imagenes";
  45. while ($file=readdir($dir)){
  46. $auxiliar = explode(".", $file);
  47. if($auxiliar[1] == "jpg"
  48. echo "<img src='imagenes/$file'><br>";
  49. }
  50. ?>
  51. </td>
  52. </tr>
  53. </table>
  54. </body>
  55. </html>


y por otro lado tengo esto para redimensionar las fotos
Código PHP:
Ver original
  1. <html>
  2. <head>
  3. <title>Subir imagenes y mostrarlas</title>
  4.  
  5. </head>
  6. <body>
  7. <?
  8.     include ("imageresize.class.php");
  9.  
  10.     $source = './imagenes/mike.png'; // solo cambio esta imagen
  11.     $dest = './imagenes/thumbs/th_mike.png';
  12.    
  13.     $oResize = new ImageResize($source);
  14.    
  15.    
  16. ?>
  17. <h2>Original</h2>
  18. <img src='<?php echo $source?>' />
  19. <br />
  20. Tama&ntilde;o: <?php echo $oResize->width_s. "x".$oResize->height_s ?><br />
  21. <form action="" method='get'>
  22. <input type="radio" name="tipo" value="width_height" /> Por ancho y largo <br />
  23. <input type="radio" name="tipo" value="width" /> Por ancho <br />
  24. <input type="radio" name="tipo" value="height" /> Por alto <br />
  25. <input type="radio" name="tipo" value="area" /> Por porcentaje de area
  26. <br />
  27. Ancho: <input type="text" name="width" size="5" />
  28. <br />
  29. Alto: <input type="text" name="height" size="5" />
  30. <br />
  31. Porcentaje: <input type="text" name="perc" size="5" />
  32.  
  33. <br />
  34. <input type='submit' value="Enviar"/>
  35. </form>
  36. <?php
  37. if (!empty($_GET['tipo'])) {
  38.     switch ($_GET['tipo']) {
  39.         case 'width_height':
  40.             $sTipo=sprintf("Por ancho y alto:%d x %d",$_GET['width'], $_GET['height']);
  41.             $oResize->resizeWidthHeight($_GET['width'], $_GET['height']);
  42.             break;
  43.  
  44.         case 'width':
  45.             $sTipo=sprintf("Por ancho:%d",$_GET['width']);
  46.  
  47.         $oResize->resizeWidth($_GET['width']);
  48.             break;
  49.  
  50.         case 'height':
  51.             $sTipo=sprintf("Por alto:%d", $_GET['height']);
  52.        
  53.             $oResize->resizeWidth($_GET['height']);
  54.             break;
  55.  
  56.         case 'area':
  57.             $sTipo=sprintf("Por area:%d%%", $_GET['perc']);
  58.  
  59.             $oResize->resizeArea($_GET['perc']);
  60.             break;
  61.     }
  62.     $oResize->save($dest);
  63. ?>
  64. <h2>Procesada</h2>
  65. <strong>Tipo de transformaci&oacute;n</strong>: <? echo $sTipo ?><br />
  66. <img src='<? echo $dest?>' />
  67. <?
  68. }
  69. ?>
  70.  
  71.  
  72. </body>
  73. </html>


y me sirve para redimencionar solo 1 foto (a la que estoi llamando)
como ago para meter las fotos que guardo arriba en una varialbe y despues a esa variable
aplicarle la redimension????
__________________
- Ingeniero en Informática -