Hei, from Php oop file upload, i update the script with some function. Size check function and extension check function. But somewhere i go wrong with extension check function.
<?php
class upload{
public $src = "upload/";
public $tmp;
public $filename;
public $typefl;
public $uploadfile;
public $type = array("php", "css", "js", "html", "htm", ".php");
function __construct(){
$this -> filename = $_FILES["file"]["name"];
$this -> tmp = $_FILES["file"]["tmp_name"];
$this -> uploadfile = $this -> src . basename($this -> filename);
}
public function sizeck(){
if($_FILES["file"]["size"] > 50000000){
echo "Fisier prea mare";
return true;
}
}
public function extens(){
$this -> typefl = pathinfo($this -> tmp, PATHINFO_EXTENSION);
if(in_array($this -> typefl, $this -> type)){
echo "Fisier nepermis!!!";
return false;
}
else{
return true;
}
}
public function uploadfile(){
if(move_uploaded_file($this -> tmp, $this -> uploadfile)){
return true;
}
}
}
?>
And call upload is :
<?php
if(isset($_FILES['file'])){
$fileupload = new upload();
if(!$fileupload -> sizeck()){
if(!$fileupload -> extens()){
if($fileupload -> uploadfile()){
echo 'Fisierul a fost uploadat';
}
}
}
}
?>
Where i do wrong and why??