Skip to content

Instantly share code, notes, and snippets.

@nailton
Last active December 20, 2015 08:18
Show Gist options
  • Save nailton/6099029 to your computer and use it in GitHub Desktop.
Save nailton/6099029 to your computer and use it in GitHub Desktop.
<?php
try {
$arquivos = parsePostSegundaEtapa();
// echo $_SESSION['imagen'];
$path = realpath(dirname(__FILE__)) . "/../../images/upload/";
die($path);
// -- Criando o diretório de armazenamento dos anexos da proposta
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
// -- Armazenando os arquivos para posterior validação
foreach ($arquivos as $arquivo => $infoArquivo) {
$ext = strtolower($infoArquivo['ext']);
if (!move_uploaded_file($infoArquivo['tmp_name'], "{$path}{$arquivo}.{$ext}")) {
$e = new Exception('Não foi possível realizar o armazenamento do arquivo.');
throw $e;
}
}
} catch (Exception $e) {
echo "Erro: ".$e->getMessage();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment