<?php
/*
CRIADO POR: K88
DATA ULTIMA ALTERAÇÃO: 16/08/2017 14:35
OBS.: ATUALIZAÇÃO DE NOVOA ESTRUTURA E REVISÃO
*/

include("../configuracao.php");//confirma no banco de dados
include("../inclusos/funcoes.php");
include("../seguranca.php"); // Inclui o arquivo com o sistema de seguran?a
protegePagina(); // Protege a página	

if(isset($_FILES["file"]["type"]))
{
$validextensions = array("jpeg", "jpg", "png");
$temporary = explode(".", $_FILES["file"]["name"]);
$file_extension = end($temporary);
if ((($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/jpeg")
) && ($_FILES["file"]["size"] < 100000)//Approx. 100kb files can be uploaded.
&& in_array($file_extension, $validextensions)) {
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br/><br/>";
}
else
{
//if (file_exists("upload/" . $_FILES["file"]["name"])) {
//echo $_FILES["file"]["name"] . " <span id='invalid'><b>already exists.</b></span> ";
//}
//else
//{
$sourcePath = $_FILES['file']['tmp_name']; // Storing source path of the file in a variable
$targetPath = "public_html/grupomax/arquivos/uploads/".$_FILES['file']['name']; // Target path where file is to be stored
move_uploaded_file($sourcePath,$targetPath) ; // Moving Uploaded file
echo "<span id='success'>Upload de Imagem efetuado Com Sucesso...!!</span><br/>";
echo "<br/><b>File Name:</b> " . $_FILES["file"]["name"] . "<br>";
echo "<b>Type:</b> " . $_FILES["file"]["type"] . "<br>";
echo "<b>Size:</b> " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "<b>Temp file:</b> " . $_FILES["file"]["tmp_name"] . "<br>";
echo "<b>Cod Cliente:</b> " . $_GET["idcliente"] . "<br>";
//}
}
}
else
{
echo "<span id='invalid'>***Invalid file Size or Type***<span>";
}
}

?>