I have this chunk of code, I want to write a file to the server and save it to DB, the problem is that file is not saved.
if (($_FILES['thumbnail']['name']!="")){
$target_dir = "img/";
$file = $_FILES['thumbnail']['name'];
$path = pathinfo($file);
$filename = $path['filename'];
$ext = $path['extension'];
$temp_name = $_FILES['thumbnail']['tmp_name'];
$path_filename_ext = $target_dir.$filename.".".$ext;
var_dump(move_uploaded_file($temp_name,$path_filename_ext));
}
In errors it returns this:
Warning
: move_uploaded_file(img/textak.txt): failed to open stream: Permission denied in
/home/kloucto2/www/create_new_article.php
on line
21
Warning
: move_uploaded_file(): Unable to move '/tmp/phpxRsCsr' to 'img/textak.txt' in
/home/kloucto2/www/create_new_article.php
on line
21
bool(false)
The form looks like this:
<form id="article-form" class="login-form" enctype="multipart/form-data" method="POST" action="">
<label for="thumbnail">Vyber thumbnail pro článek:</label>
<input type="file" form='article-form' id="thumbnail" name="thumbnail">
</form>