I'm trying make a file upload using PHP. To do it I'm using $_FILE but I can't understand why does not works. Looking for solutions I'm found some suggestion to use $_FILE, but still can't do this works. To I see if upload works I'm using Postman of Chrome. I'm using Ubuntu with LAMP.
How could I do it ?
<?php
$arquivo = isset($_FILES["file"]) ? $_FILES["file"] : FALSE;
if(!$arquivo) {
echo "You can not access this file directly!";
}else{
$diretorio = "/home/fernando/Imagens/";
if (move_uploaded_file($arquivo["tmp_name"], $diretorio.$arquivo["name"])) {
echo "File upload ok!";
}else{
echo "File not upload!";
}
}
?>
Exception
<br />
<b>Warning</b>: move_uploaded_file(/home/fernando/Imagens/avatar_empresa.jpg): failed to open stream: Permission denied in
<b>/var/www/TelefonesUteis/ws/add_file.php</b> on line
<b>12</b>
<br />
<br />
<b>Warning</b>: move_uploaded_file(): Unable to move '/tmp/phpq9AlVw' to '/home/fernando/Imagens/avatar_empresa.jpg' in
<b>/var/www/TelefonesUteis/ws/add_file.php</b> on line
<b>12</b>
<br />
Postman