0
$dir = "arquivo/";
$file = $_FILES["csv1"];
//Move o arquivo da pasta temporaria de upload para a pasta de destino
if (move_uploaded_file($file["tmp_name"], "$dir/".$file["name"])) {
rename($file["name"], "novonome.csv");
echo "Arquivo enviado com sucesso!";
}
else {
echo "Erro, o arquivo não pode ser enviado.";
}
Error:
Warning: Rename(dados.csv,novonome.csv): Permission denied in /var/www/html/importador_de_csv/file.php on line 11
I have tried to give permission to the folder and the file, I just need to rename it after changing it from folder
Read this manual will help you. https://php.net/rename
– DbaAlone
Use the path to the file, not just the name:
rename($file["tmp_name"], "$dir/novonome.csv")
– Costamilam
you can already pass its new name inside the function 'move_uploaded_file' example: move_uploaded_file($file["tmp_name"], "$dir/". $novonome)
– Luan Brito