include('../login/acesso.php');
include('classes.php');
$class_fotos = new fotos_funcoes();
if (isset($_POST['nome'])) {
$nome = $class_ferramentas->anti_injection($_POST['nome']);
}
if (isset($_POST['id_cliente'])) {
$id_cliente = $class_ferramentas->anti_injection_texto($_POST['id_cliente']);
}
if (isset($_POST['status'])) {
$status = $class_ferramentas->anti_injection_texto($_POST['status']);
}
if (isset($_POST['data'])) {
$data = $class_ferramentas->anti_injection_texto($_POST['data']);
}
if (isset($_POST['texto'])) {
$texto = $class_ferramentas->anti_injection_texto($_POST['texto']);
}
$adicionar = $class_fotos->fotos_adicionar($nome, $texto, $status, $data);
$id_ = $adicionar['id_'];
$pasta_ = "fotos";
$folder = 'img/'.$id_.'/';
$pasta_id_ = 'img/'.$id_.'/';
if (!file_exists($pasta_id_)){
mkdir("$pasta_id_", 0777);
$pasta_id_2 = 'img/'.$id_.'/fotos_albun';
if (!file_exists($pasta_id_2)){
mkdir("$pasta_id_2", 0777);
}
}
//REQUISITOS
$permite = array('image/jpeg', 'image/png');
$maxSize = 1024 * 1024 * 5;
$file = $_FILES['imagem'];
$name = $file['name'];
$type = $file['type'];
$size = $file['size'];
$error = $file['error'];
$tmp = $file['tmp_name'];
$extensao = @end(explode('.', $name));
$novoNome = rand().".$extensao";
if($file) {
if($error != 0) {
$msg = "$name : ".$errorMsg[$error];
} else if(!in_array($type, $permite)) {
$msg = "$name : Erro imagem não suportada!";
} else if($size > $maxSize){
$msg = "$name : Erro imagem ultrapassa o limite de 5MB";
} else {
if(move_uploaded_file($tmp, $folder.'/'.$novoNome)) {
$photo_dest = 'img/'.$id_.'/'.$novoNome;
$msg = " $name : Upload Realizado com Sucesso!";
$atualizar_url_foto = $class_fotos->atualizar_url_logomarca($id_,$photo_dest);
// echo "";
} else {
$msg = "$name : Desculpe! Ocorreu um erro...";
// echo "";
}
}
}
if($adicionar['status'] == 1){
$id_ = $adicionar['id_'];
$msg = $adicionar['mensagem'];
echo "";
} else {
$msg = $adicionar['mensagem'];
echo "";
}
?>