Bem pessoal, to precisando da ajuda de quem entende da area de scripts para alterar na web trds a pagina que serve para fazer upload de imagens, tanto para chars, banners de guild, e screenshots. Gostaria que fosse adicionado nele para fazer upload de imagens em formato .gif e .png
Obrigado
Seria esse Script.
Código PHP:
<?
if (basename($_SERVER["REQUEST_URI"]) === basename(__FILE__))
{
exit();
}
class nwUpload extends conexao
{
var $Size;
var $Directory;
var $Archive = "";
var $Name = "";
var $Pixels;
var $Reduce = true;
var $execQuery = false;
var $Dados = array();
var $Error = array();
function Check()
{
$this->Archive = isset($_FILES["arquivo"]) == true ? $_FILES["arquivo"] : false;
$get = getimagesize($this->Archive["tmp_name"]);
if (is_uploaded_file($this->Archive["tmp_name"]) == false)
{
$this->Error[] = "Não foi possivel enviar a imagem.";
}
if ($get["mime"] != "image/jpeg")
{
$this->Error[] = "Formato inválido.<br />A imagem deve estar no formato <strong>JPEG</strong>.";
}
if ($this->Archive["size"] > $this->Size)
{
$this->Error[] = "A imagem ultrapasso o limite de <strong>{$this->Size}(Bytes)</strong>";
}
return true;
}
function Send()
{
if ($this->Check() == true)
{
$this->Generate();
}
}
function Generate()
{
if (file_exists($this->Directory) == false)
{
$this->Error[] = "O diretório não existe.";
}
if (count($this->Error) > 0)
{
foreach ($this->Error as $Err)
{
echo("<blockquote class=\"error\">{$Err}<br /></blockquote>");
return false;
}
}
else
{
$Image = $this->Directory.$this->Name.".jpg";
if ($this->Reduce == true)
{
$this->Collapse($this->Archive["tmp_name"], $Image, $this->Pixels);
}
else
{
move_uploaded_file($this->Archive["tmp_name"], $Image);
}
if ($this->execQuery == true)
{
$this->query("insert into wt_screens (author,votes,description,data) values ('{$this->Dados[1]}',0,'{$this->Dados[2]}',{$this->Dados[0]})");
}
echo("<blockquote class=\"success\">Imagem '<strong>{$this->Name}.jpg</strong>' enviada com sucesso.</blockquote>");
return true;
}
}
function Collapse($Name, $Image, $Pixels)
{
$get = getimagesize($Name);
$obj = explode(",", $Pixels);
$obj[0] = $obj[0];
$obj[1] = $obj[1];
$imgCreate = imagecreatetruecolor($obj[0], $obj[1]);
$ImageJpeg = imagecreatefromjpeg($Name);
imagecopyresampled($imgCreate, $ImageJpeg, 0, 0, 0, 0, $obj[0], $obj[1], $get[0], $get[1]);
return imagejpeg($imgCreate, $Image, 250);
imagedestroy($ImageJpeg);
}
}
?>