Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/10/2012, 13:30
wayward
(Desactivado)
 
Fecha de Ingreso: enero-2004
Mensajes: 136
Antigüedad: 20 años, 3 meses
Puntos: 0
Cambio tamaño y crear miniaturas

Hola.

Me gustaria saber como podria cambiar de tamaño las imagenes cuando se suban al servidor y tambien como crear miniaturas.


El codigo que recoge los datos del formulario es el siguiente:
Código PHP:
Ver original
  1. <?php
  2. global $upload_folder_path;
  3. if(!$current_user->data->ID)
  4. {
  5.     wp_redirect(get_settings('home').'/index.php?page=login');
  6.     exit;
  7. }
  8. global $wpdb,$General;
  9. //$_SESSION['ads_information_session'] = '';
  10.  
  11. $user_path = array();
  12. $user_path = $_POST['hidden_image'];
  13. $hidden_image = $_POST['hidden_image'];
  14.  
  15.  
  16.  
  17. foreach($_POST as $key=>$val)
  18. {
  19.     $_POST[$key] = stripslashes($val); 
  20. }
  21.  
  22. if(count($_FILES['images']['name'])>0)
  23. {
  24.     $generalinfo = $General->get_general_settings();
  25.     if($generalinfo['imagepath'])
  26.     {
  27.         $imagepath = $generalinfo['imagepath'];
  28.     }else
  29.     {
  30.         $imagepath = 'products_img';
  31.            
  32.     }
  33.    
  34.    
  35.     $destination_path = ABSPATH . "$upload_folder_path".$imagepath."/";
  36.    
  37.     if (!file_exists($destination_path))
  38.     {
  39.         $imagepatharr = explode('/',$upload_folder_path."$imagepath");
  40.         $year_path = ABSPATH;
  41.         for($i=0;$i<count($imagepatharr);$i++)
  42.         {
  43.           if($imagepatharr[$i])
  44.           {
  45.              $year_path .= $imagepatharr[$i]."/";
  46.               if (!file_exists($year_path)){
  47.                   mkdir($year_path, 0777);
  48.               }    
  49.             }
  50.         }
  51.      $imagepatharr = explode('/',$imagepath);
  52.        $upload_path = ABSPATH . "$upload_folder_path";
  53.       if (!file_exists($upload_path)){
  54.         mkdir($upload_path, 0777);
  55.       }
  56.      
  57.      
  58.      
  59.      
  60.       for($i=0;$i<count($imagepatharr);$i++)
  61.       {
  62.           if($imagepatharr[$i])
  63.           {
  64.               $year_path = ABSPATH . "$upload_folder_path".$imagepatharr[$i]."/";
  65.               if (!file_exists($year_path))
  66.               {
  67.                   mkdir($year_path, 0777);
  68.               }    
  69.               @mkdir($destination_path, 0777);
  70.         }
  71.       }
  72.     }
  73.    
  74.        
  75.    
  76.     for($i=0;$i<count($_FILES['images']['name']);$i++)
  77.     {
  78.         $a1 = $_FILES['images']['name'][$i];
  79.         $a2 = substr ($a1,-3);
  80.         $ran = rand () ;
  81.         $name = time().'_'.$ran.$i.'.'.$a2;
  82.         $tmp_name = $_FILES['images']['tmp_name'][$i];
  83.         $target_path = $destination_path . str_replace(',','',$name);
  84.         if(@move_uploaded_file($tmp_name, $target_path))
  85.         {
  86.             $imagepath1 = get_option( 'siteurl' ) ."/$upload_folder_path".$imagepath."/".$name;
  87.             $upload_path = get_option('upload_path');
  88.             $imagepath1 = str_replace($upload_path,'files',$imagepath1);
  89.             $user_path[] = $imagepath1;
  90.             $result = 1;
  91.            
  92.        
  93.         }
  94.     }
  95. }
  96.  
  97. ?>

Muchas gracias.