Allowed doesn't work

See all posts Reply

Allowed doesn't work new!
by Elias, 13 years, 11 months ago
Hi There

I've been used this code:
if($_FILES) {
  include("class.upload.php");
  $handle = new upload($_FILES['image']);
  if ($handle->uploaded) {
    $handle->process($dir);
    $handle->allowed = array("image/*");
    $handle->forbidden = array("application/*","text/*");
    if ($handle->processed) {
      echo 'Imagem enviada!';
      $handle->clean();
    } else {
      echo 'error : ' . $handle->error;
    }
  }
}


But i can upload any mime type. What's the problem?Reply
Re: Allowed doesn't work new!
by colin, 13 years, 11 months ago
You need to add the allowed and forbidden before the call to process()Reply
Re: Allowed doesn't work new!
by mustafa , 4 years, 7 months ago
hi it doesnt work
if ($this->my_upload->uploaded === true) {
$this->my_upload->allowed = array('application/pdf','application/msword');
//$this->my_upload->allowed=array( 'image/*');
$this->my_upload->file_new_name_body = $this->alias;
// $this->my_upload->jpeg_quality = $this->quality;
$this->my_upload->file_max_size = "20M";
$this->my_upload->file_auto_rename=TRUE;
$this->my_upload->file_overwrite = FALSE;
//$this->my_upload->image_convert = 'jpg';
$this->my_upload->process ( $this->file_path[$typ]);

if($this->my_upload->processed){
$fileInfo["name"] = formatUrl($this->alias);
$fileInfo["cuser"]=$this->session->userdata('id');
$fileInfo["typ"]=$typ;
$fileInfo["pub"]="y";
$fileInfo["ext"]=$this->my_upload->file_dst_name_ext;
$fileInfo["size"]=filesize($this->file_path[$typ].$fileInfo["name"].".".$fileInfo["ext"]);
$fileInfo["position"]="top";

$this->load->model ( Array ('simple_model' ) );
$last_file_id = $this->insert_data("file",$fileInfo);


$this->thumb = $this->simple_model->select("thumb");
if($page_id!=""){
$this->insert_data("filecross",Array("master"=>$page_id,"detail"=>$last_file_id));
}
$this->load->library('my_lang');
$translate_list=$this->my_lang->getTranslateList();
foreach($translate_list as $tl=>$tlVal){
$tVal["header"] = $this->input->post('header-'.$tlVal["alias"]);
$tVal["content"] = $this->input->post('content-'.$tlVal["alias"]);
$tVal["alt"] = $this->input->post('alt-'.$tlVal["alias"]);
$tVal["tag"] = $this->input->post('tag-'.$tlVal["alias"]);
$tVal["lng"] = $tlVal["alias"];
$tVal["refId"] = $last_img_id;
if($tVal["header"]!="" || $tVal["alt"]!="" || $tVal["content"]!=""){
$this->insert_data("filetxt",$tVal);
}
unset($tVal);
}

echo json_encode(['status' => 'ok','path' => $this->file_path[$typ]]);
}else{
echo json_encode(['status' => 'error','path' => $this->file_path[$typ]]);
}
} else {
echo json_encode(['status' => 'error','path' => $e->getMessage()]);
}Reply
Re: Allowed doesn't work new!
by colin, 4 years, 7 months ago
Please check the log produced by the class.Reply