<?php
include("baseClass/uploadEngineClass.php");
class uploadImage extends uploadFile {
/*#
#
# Son Class
#
# Version: 1.0
#
#
*/#
var $maxWidth;
var $maxHeight;
var $maxSize;
var $parmsType;
var $nameUnique;
var $extension_de;
function uploadImage($name,$tmp_name,$size,$type,$erro="0"){
$this->uploadFile($name,$tmp_name,$size,$type,$erro);
$this->extension_de=array();
}
function setMaxHeight ($value) {
$this->maxHeight=$value;
}
function setMaxWidth ($value) {
$this->maxWidth=$value;
}
function setMaxSize ($value) {
$this->maxSize=$value;
}
function setDestinationImage($tmp,$dir){
$this->setDestinationFile($tmp,$dir);
}
function newNameFile ($prefix_name="Img",$more_entropy=false) {
$extensao=explode(".",$this->fileName);
$name=uniqid($prefix_name,$more_entropy);
$this->fileName=$name.".".$extensao[1];
}
function setExtension ($extension) {
array_push($this->extension_de,$extension);
}
function getName () {
return $this->fileName;
}
function getExtension () {
$file=$this->getName();
$setPart=explode(".",$file);
$extension=end($setPart);
if(in_array($extension,$this->extension_de)) {
return true;
}else{
return false;
}
}
function moveImage(){
if($this->moveFile()) {
$parms=getimagesize($this->fileDestinationTmp.$this->fileName);
$xx=$parms['0'];
$yy=$parms['1'];
if($xx>$this->maxHeight and $yy>$this->maxWidth) {
$this->fileUnlink($this->fileDestinationTmp.$this->fileName);
return false;
}else{
if($this->fileSize>$this->maxSize) {
$this->fileUnlink($this->fileDestinationTmp.$this->fileName);
return false;
}else{
if($this->getExtension()) {
if($this->copyFile($this->fileDestinationTmp,$this->fileDestination)) {
$this->fileUnlink($this->fileDestinationTmp.$this->fileName);
return true;
}else{
$this->fileUnlink($this->fileDestinationTmp.$this->fileName);
return false;
}
}else{
$this->fileUnlink($this->fileDestinationTmp.$this->fileName);
return false;
}
}
}
}
}
}
|