global variables for class.upload.php

See all posts Reply

global variables for class.upload.php new!
by Taner Macit, 10 years ago
I want to use pre options of class.upload.php variables in the class. Becuse i repeat thiş setting in all of my upload pages and when i wan to make a little change i must change all of this variables , i need a solution that i can add this preoptions as a variable or as a function or _construct..
if ((isset($_POST['actionmanset']) ? $_POST['actionmanset'] : (isset($_GET['actionmanset']) ?   $_GET['actionmanset'] : '')) == 'manset') {
 $handle = new Upload($_FILES['resim']);
  if ($handle->uploaded) {
    
    //common variables i want to use start
    $handle->auto_create_dir  = FALSE;
    $handle->file_max_size = '5000000'; // 4mb
    $handle->mime_check    = TRUE; #Güvenlik
    $handle->allowed = array('image/jpeg','image/gif','image/png'); #Güvenlik Yalnız resim
    $handle->no_script = true; #güvenlik
    $handle->image_resize          = true;
    $handle->image_ratio_crop      = true;
    $handle->file_auto_rename = true; 
    $handle->file_name_body_pre = 'tt_';
    //common variables i want to use finish

    $handle->image_x               = 427;
    $handle->image_y               = 225;
    $handle->Process('../uploads/manset/');
    if ($handle->processed) { $mansetresmi=$handle->file_dst_name;}
  }
}

how can i keep this global variables to use again in all my pages.Reply
Re: global variables for class.upload.php new!
by colin, 10 years ago
You can do it with simple PHP (not tested):
$options = array(
  'auto_create_dir' => FALSE,
  'file_max_size' => '5000000', 
  'mime_check' => TRUE, 
  'allowed' => array('image/jpeg','image/gif','image/png'),
  'no_script' => true, #güvenlik
  'image_resize' => true,
  'image_ratio_crop' => true,
  'file_auto_rename' => true, 
  'file_name_body_pre' => 'tt_'
);

$handle = new Upload($_FILES['resim']);
if ($handle->uploaded) {
  // assign the array values to the class properties
  foreach ($options as $key => $value) {
    $handle->$key = $value;
  }
}
Reply