1
I have a problem in the way to save the upload file. I have a php file that does the update that is in the process folder, and an upload folder to save the files that were saved.
$id = $_POST['id'];
$titulo = $_POST['titulo'];
$descricao = $_POST['descricao'];
$postador = $_POST['postador'];
$arquivo = $_FILES['arquivo']['name'];
//Substituindo os caracteres especiais
$original =
'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜüÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿRr"!@#$%&*
()_-+={[}]/?;:,\\\'<>°ºª';
$substituir =
'aaaaaaaceeeeiiiidnoooooouuuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr
';
$arquivo = strtr(utf8_decode($arquivo), utf8_decode($original),
$substituir);
//Substitui os espaços em branco
$arquivo = str_replace(' ', '-', $arquivo);
//Substitui os Maiúsculos por Minúsculos
$arquivo = strtolower($arquivo);
$caminhofinal = "upload".'/'.$arquivo;
move_uploaded_file($_FILES['arquivo']['tmp_name'],$caminhofinal);
$sql_query = "UPDATE posts SET titulo = '$titulo', arquivo =
'$caminhofinal', descricao = '$descricao', data = NOW(), hora = NOW(),
postador = '$postador' WHERE id = '$id'";
$resultado = mysqli_query($mysqli, $sql_query);
if($resultado === TRUE){
$_SESSION['msg'] = "<div class='alert alert-success alert-dismissable'>
<a href='#' class='close' data-dismiss='alert' aria-
label='close'>×</a>
ID: $id Editado com Sucesso!</div>";
header("Location: ../professor/lista_conteudo.php");
} else {
$_SESSION['msg'] = "<div class='alert alert-danger'>
<a href='#' class='close' data-dismiss='alert' aria-
label='close'>×</a>
Erro ao Editar ID: $id</div>";
header("Location: ../professor/editar_conteudo.php");
}
The point is that you are saving the url in the database but not the file in the folder. I have tried putting in the variable $camiofinal = ".. /upload". '/'. $file; but it didn’t work. Can anyone help me? Thanks!
It may be folder permission, try to put write permission in your final path folder
– Gabriel Santos