daily pastebin goal
60%
SHARE
TWEET

Upload Dream Gallery

a guest Oct 8th, 2014 221 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. require_once '../database/mysql.php';
  4. require_once '../class/Session.class.php';
  5. require_once '../class/Upload.class.php';
  6. $db = new Mysql;
  7. $sid = new Session;
  8. $sid->start();
  9.  
  10.  
  11. $file_dst_name = "";
  12. $album_id = $_GET['album_id'];
  13. $dir_dest = '../fotos';
  14. $file = $_FILES['Filedata'];
  15.  
  16.  
  17.     $handle = new Upload( $file );
  18.     if ( $handle->uploaded )
  19.     {
  20.         $handle->file_overwrite = true;
  21.         $handle->image_convert = 'jpg';
  22.         //Configuracoes de redimensionamento retrato
  23.         $lMax  = 2000; //largura maxima permitida
  24.         $aMax  = 1600; // altura maxima permitida
  25.         //Configuracoes de redimensionamento paisagem
  26.         $plMax = 1800; //largura maxima permitida
  27.         $paMax = 1400; // altura maxima permitida
  28.  
  29.  
  30.         if ( $handle->image_src_x > $handle->image_y )
  31.         {
  32.             if ( $handle->image_src_x > $lMax || $handle->image_y > $aMax )
  33.             {
  34.                 $handle->image_resize = true;
  35.                 $handle->image_ratio = true;
  36.                 $handle->image_x = ($lMax / 2);
  37.                 $handle->image_y = ($aMax / 2);
  38.             }
  39.         }
  40.         else
  41.         {
  42.             if ( $handle->image_src_x > $plMax || $handle->image_y > $paMax )
  43.             {
  44.                 $handle->image_resize = true;
  45.                 $handle->image_ratio = true;
  46.                 $handle->image_x = ($plMax / 2);
  47.                 $handle->image_y = ($paMax / 2);
  48.             }
  49.         }
  50.  
  51.         $handle->file_new_name_body = md5( uniqid( $file['name'] ) );
  52.         $handle->process( $dir_dest );
  53.         if ( $handle->processed )
  54.         {
  55.             $file_dst_name = $handle->file_dst_name;
  56.             $foto_data = date( 'Y-m-d 00:00:00' );
  57.             $db->query( "insert into fotos (foto_album,foto_url,foto_data,foto_pos) values ($album_id,'$file_dst_name','$foto_data','999');" );
  58.             //$file_dst_name .= "?v=" . time();
  59.             $last_id = mysql_insert_id();
  60.             echo json_encode( array( 'url' => "$file_dst_name", 'id' => $last_id, 'time' => time() ) );
  61.         }
  62.         else
  63.         {
  64.             echo json_encode( array( 'url' => "error", 'id' => '', 'time' => time() ) );
  65.         }
  66.     }
  67.         else
  68.         {
  69.             echo json_encode( array( 'url' => "error", 'id' => '', 'time' => time() ) );
  70.         }      
  71.  
  72. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top