Answer the question
In order to leave comments, you need to log in
Why doesn't move_upload_files move files?
if (isset($_FILES['image']) && $_FILES['image']['error'] === 0) {
$type_arr = ['image/jpeg', 'image/png', 'image/gif', 'image/bmp'];
if (in_array($_FILES['image']['type'], $type_arr)) {
$fileNameCmps = explode(".", $_FILES['image']['name']);
$ext = strtolower(end($fileNameCmps));
echo $dir = str_replace('\\', '/', __DIR__ . '/../../../../image/users/' . $this->id . '.' . $ext);
if (move_uploaded_file($_FILES['tmp_name'], $dir)) {
$this->image = $this->id . '.' . $ext;
} else {
throw new \Exception('При перемещении изображения произошла ошибка!');
}
} else {
throw new InvalidFormatException('Картинки должны быть формата: jpg, jpeg, png, gif, bmp');
}
} else {
throw new \Exception('При загрузке изображения произошла ошибка!');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question