This code should upload files, but it doesn't.
<form name="submit" action="#" method="post" enctype="multipart/form-data">
<input type="file" value="Choose file" id="pic" name="pic">
<input type="submit" value="Upload" name="submit">
</form>
<?php
ini_set('display_startup_errors', 1).'<br>';
ini_set('display_errors', 1).'<br>';
error_reporting(-1).'<br>';
session_start();
$pic = $_FILES["pic"]["name"];
$folder = 'projects';
$path = $folder.'/'.$pic;
if (!is_writeable($path)) {
die("Cannot write to destination file");
}
else{
move_uploaded_file($_FILES["pic"]["tmp_name"], $path);
echo $path.'<br>';
echo 'DONE';
}
print_r($_FILES);
?>
Files on server are owned by www-data. Target folder is owned by www-data and has 0777 permissions. No major errors. And yet it says "Cannot write to destination file".
Any ideas how to resolve this, would be appreciated.