Добрый день!
Творятся странные дела - метод move_uploaded_file не работает, пытаюсь полдня решить.
FastCGI - подключен
Permissions - 755
JQUERY Обработчик с веба - работает
vardump с $_FILES:
array(1) {
["files"]=>
array(5) {
["name"]=>
string(12) "Group--1.png"
["type"]=>
string(9) "image/png"
["tmp_name"]=>
string(44) "/var/www/demo_gromi_f_usr/data/tmp/phpgJ2zy5"
["error"]=>
int(0)
["size"]=>
int(4470)
}
}
Содержимое Upload.php:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_FILES['files'])) {
$errors = [];
$extensions = ['jpg', 'jpeg', 'png', 'gif'];
$target = $_SERVER['DOCUMENT_ROOT'] . '/uploads/';
$target = $target . basename($doc);
$all_files = count($_FILES['files']['tmp_name']);
for ($i = 0; $i < $all_files; $i++) {
$file_name = $_FILES['files']['name'];
$file_tmp = $_FILES['files']['tmp_name'];
$file_type = $_FILES['files']['type'];
$file_size = $_FILES['files']['size'];
$file_ext = strtolower(end(explode('.', $_FILES['files']['name'])));
$file = $target . $file_name;
if (!in_array($file_ext, $extensions)) {
$errors[] = 'Extension not allowed: ' . $file_name . ' ' . $file_type;
}
if ($file_size > 2097152) {
$errors[] = 'File size exceeds limit: ' . $file_name . ' ' . $file_type;
}
if (empty($errors)) {
move_uploaded_file($file_tmp, $file);
var_dump($_FILES);
// echo $target;
}
}
if ($errors) print_r($errors);
}
}
?>