2014-11-23 3 views
0

클래스의 class.upload.php 변수의 사전 옵션을 사용하고 싶습니다. 모든 업로드 페이지에서 설정을 반복하고이 변수를 모두 변경해야한다면 약간의 변경을해야 할 때 변수 나 함수 또는 구문으로이 선행 옵션을 추가 할 수있는 솔루션이 필요합니다.클래스에서 전역 변수를 사용하는 방법

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;} 

        } 

    } 

어떻게이 전역 변수를 모든 내 페이지에서 다시 사용할 수 있습니까?

//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 
+0

을 반환 할 수 있습니다 필드 선언을 변경하고 페이지를 다시 정의해야합니다. –

+0

class.upload.php라는 클래스와 upload.php라는 파일이 있으므로 _construct, class 또는 file을 추가해야합니다. – Bagova

+0

'클래스 업로드 '를 정의하는 파일은 무엇입니까? –

답변

0

당신은 $ _SESSION 변수

에 넣어 아니면 get 함수를 작성하고 당신의`__construct` 나에 모두 기입이 변수를

1
Class GlobalsTT{ 
    public $auto_create_dir = FALSE; 
    public $file_max_size = '5000000'; // 4mb 
    public $mime_check = TRUE; #Güvenlik 
    public $allowed = array('image/jpeg','image/gif','image/png'); #Güvenlik Yalnız resim 
    public $no_script = true; #güvenlik 
    public $image_resize   = true; 
    public $image_ratio_crop  = true; 
    public $file_auto_rename = true; 
    public $file_name_body_pre = 'tt_'; 

    public function set($variable_name,$value){ 

     $this-$variable_name = $value ; 

    } 

    public function get($variable_name){ 

    return $this->$variable_name; 

    } 

    } 

if ((isset($_POST['actionmanset']) ? $_POST['actionmanset'] : (isset($_GET['actionmanset']) ? $_GET['actionmanset'] : '')) == 'manset') { 
ichbar($_FILES["resim"]["name"]); 
$handle = new Upload($_FILES['resim']); 

if ($handle->uploaded) { 
    //Orjinal Dosya 
    $globals = new GlobalsTT(); 
    $handle->image_x    = 427; 
    $handle->image_y    = 225; 
    $handle->Process('../uploads/manset/'); 

    //145 lık thumbnail 
    $globals = new GlobalsTT(); 
    $handle->image_x    = 145; 
    $handle->image_y    = 76; 
    $handle->Process('../uploads/manset/145/'); 

    $thumb_result = $handle->processed; 
    $thumb_width = $handle->image_dst_x; 
    $thumb_height = $handle->image_dst_y; 

if ($handle->processed) { $mansetresmi=$handle->file_dst_name;} 
    else { $err='Resminiz sadece jpg, png ya da gif formatında ve maksimum 4 mb büyüklüğünde olmalıdır. Detaylı Hata Ayrintisi:' . $handle->error . ''; 
    echo '<script type="text/javascript">alert("'.$err.'");</script>'; } 
} 
} 
관련 문제