Created
February 13, 2012 17:10
-
-
Save raphaeldealmeida/1818360 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$arquivo = isset($_FILES["anexo"]) ? $_FILES["anexo"] : FALSE; | |
$arquivo_tratado = str_replace("+","-",$arquivo); | |
if(is_uploaded_file($arquivo_tratado['tmp_name'] && !empty ($erro)) | |
{ | |
$size = $_FILES[$arquivo_tratado]['size']; | |
if ($size > 10240000){ | |
$erro = "O tamanho maximo para envio de arquivo é de 10M. Por favor tente novamente."; | |
} | |
$tipo_validos = array("image/txt", "image/pdf", "image/doc", "image/docx", "image/xls", "image/xlsx", | |
"image/jpg", "image/png", "image/jpeg", "image/zip", "image/rar"); | |
$extencao = $_FILES[$arquivo_tratado]['type']; | |
if (array_search($extencao, $tipo_validos) === false){ | |
$erro = "Extenção inválida. Tipo permitidos: txt, pdf, doc, docx, xls, xlsx, jpg, png, jpeg, zip, rar"; | |
} | |
if($arquivo_tratado) | |
{ | |
// Gera um nome único para a imagem | |
$nome = $arquivo_tratado["name"]; | |
// Caminho onde o arquivo ficará | |
$arquivo_dir = $observacao_resultado_arquivo_path . $nome; | |
// Upload do arquivo | |
move_uploaded_file($arquivo_tratado["tmp_name"], $arquivo_dir); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment