0
Good afternoon, I am trying to send a php file to the server, but it is not going to the given folder and is getting "loose" in the main folder.
And also, instead of the file going to the selected folder, it is taking the name of the path. Example: List.pdf when upo it changes name to: panel/uploads/bid/
Now follow the code section where I indicate the address:
<?php
include "conexao.php";
// Lista de tipos de arquivos permitidos
$tiposPermitidos= ("application/pdf");
//var_dump($_FILES);exit;
// O nome original do arquivo no computador do usuário
$arqName = $_FILES['arquivo']['name'];
// O tipo mime do arquivo. Um exemplo pode ser "image/gif"
$arqType = $_FILES['arquivo']['type'];
// O tamanho, em bytes, do arquivo
$arqSize = $_FILES['arquivo']['size'];
// O nome temporário do arquivo, como foi guardado no servidor
$arqTemp = $_FILES['arquivo']['tmp_name'];
// O código de erro associado a este upload de arquivo
$arqError = $_FILES['arquivo']['error'];
//codigo do tipo de arquivo
$tipoArquivo = $_POST['local'];
if ($arqError == 0) {
// Verifica o tipo de arquivo enviado
if ($arqType != $tiposPermitidos) {
echo 'O tipo de arquivo enviado é inválido!';
// Não houveram erros, move o arquivo
}elseif ($tipoArquivo == 1) {
$pasta = 'painel/uploads/licitacoes/1/';
//var_dump(move_uploaded_file($arqTemp, $pasta . $arqName));exit;
$upload = move_uploaded_file($arqTemp, $pasta . $arqName);
}elseif ($tipoArquivo == 2) {
$pasta = 'painel/uploads/edital/2/';
//var_dump(move_uploaded_file($arqTemp, $pasta . $arqName));exit;
$upload = move_uploaded_file($arqTemp, $pasta . $arqName);
}elseif ($tipoArquivo == 3) {
$pasta = 'painel/uploads/legislacao/3/';
//var_dump(move_uploaded_file($arqTemp, $pasta . $arqName));exit;
$upload = move_uploaded_file($arqTemp, $pasta . $arqName);
}
}
//Verifica se o arquivo foi movido com sucesso
if ($upload == true) {
// Cria uma query MySQL
$query = mysqli_query($conectar,"INSERT INTO `pdf` (`id`, `nome`, `tipo`) VALUES (NULL, '{$arqName}', '{$tipoArquivo}')");
if ($query == true) {
header("Location: listar_pdf.php");
}
}else{
//header("Location: upload.php");
echo 'Ocorreu algum erro com o upload, por favor tente novamente!';
}
wouldn’t have to close with a / in $folder? example: $folder = 'panel/uploads/bids/1/'
– user60252
when I do, it drops to Else: }Else{ header("Location: subir_file.php"); echo 'There has been an error with the upload, please try again! '; }
– Pedro Ribeiro
1 2 3 are not folders? you have to finish with /
– user60252
That your file is in that folder?
– user60252
What I skipped? is staying in the folder "Panel", I want it to stay in the folder "panel/uploads/bids/
– Pedro Ribeiro
what sends
– user60252
On my computer
– Pedro Ribeiro
in that case, I’m sorry, I don’t know.
– user60252