Help me figure out the question / problem here:
the file that is uploaded to the server does not appear in the webroot/uploads/ folder, although the path is registered, the transfer function itself does not produce any errors ...
the oddity is that the file $full_path appears in the webroot folder, with a set of just numbers ...
the path itself in the database is saved correctly (in the form: webroot/uploads/1496868491.png )
decided to look var_dump($_FILES['img_file']) ;
array(5) { ["name"]=> string(6) "t1.png" ["type"]=> string(9) "image/png" ["tmp_name"]=> string(50) "C:\openserver\OpenServer\userdata\temp\php5875.tmp" ["error"]=> int(0) ["size"]=> int(2387) } the code itself.
path = 'webroot/uploads/'; // директория для загрузки $ext = array_pop(explode('.',$_FILES['img_file']['name'])); // расширение $new_name = time().'.'.$ext; // новое имя с расширением $full_path = $path.$new_name; // полный путь с новым именем и расширением echo "<pre>"; echo var_dump($_FILES['img_file']); echo "</pre>"; if($_FILES['img_file']['error'] == 0){ if(move_uploaded_file(($_FILES['img_file']['tmp_name']), '$full_path')){,,,,} In search of a solution, I stumbled upon the council to check the folder for writing.
if (!is_writable($path)) { die("Запись в каталог запрещена"); } else {if(move_uploaded_file(....)){...} So, the check issued that $ path is write protected, who knows how to give permission to write? (the question is what can be done through cmd, or using php)
chmodfunction, but the result of the operation will depend on whether the user from whom the nginx / apache process is running has sufficient permissions. But, this is bad practice. The upload folder must exist and have write permissions initially. - Vitaly