<?php
$valid_types = array('jpg', 'png', 'jpeg');
if (isset($_FILES['user_photo'])) {
$type = explode('/', $_FILES['user_photo']['type']);
$size = $_FILES['user_photo']['size'];
if (is_uploaded_file($_FILES['user_photo']['tmp_name'])) {
if ($_FILES['user_photo']['size'] <= 300000 && in_array($type[1], $valid_types)) {
$filename = $_FILES['user_photo']['name'];
$upl_add_dir = ROOT . '/public/images/users/';
$upl_add_file = $upl_add_dir . 'user_foto_' . $filename;
$image = $_ENV['APP_URL']. '/images/users/' . 'user_foto_' . $filename;
move_uploaded_file($_FILES['user_photo']['tmp_name'], $upl_add_file);
} else {
$text = 'This file cannot be loaded';
}
}
}
?>