claro_delete_file($picturePath); $user_data['picture'] = ''; $dialogBox->success(get_lang("User picture deleted")); } else { $dialogBox->error(get_lang("Cannot delete user picture")); } } // Handle user picture if (isset($_FILES['picture']['name']) && $_FILES['picture']['size'] > 0) { $fileName = $_FILES['picture']['name']; $fileTmpName = $_FILES['picture']['tmp_name']; if (is_uploaded_file($fileTmpName)) { if (is_image($fileName)) { list($width, $height, $type, $attr) = getimagesize($fileTmpName); if ($width > 0 && $width <= get_conf('maxUserPictureWidth', 150) && $height > 0 && $height <= get_conf('maxUserPictureHeight', 200) && $_FILES['picture']['size'] <= get_conf('maxUserPictureSize', 100 * 1024)) { $uploadDir = user_get_private_folder_path($user_data['user_id']); if (!file_exists($uploadDir)) { claro_mkdir($uploadDir, CLARO_FILE_PERMISSIONS, true); } if (false !== ($pictureName = treat_uploaded_file($_FILES['picture'], $uploadDir, '', 1000000000000.0))) { // Update Database $user_data['picture'] = $pictureName; $dialogBox->success(get_lang("User picture added")); } else { // Handle Error $dialogBox->error(get_lang("Cannot upload file")); } } else { // Handle error $dialogBox->error(get_lang("Image is too big : max size %width%x%height%, %size% bytes", array('%width%' => get_conf('maxUserPictureWidth', 150), '%height%' => get_conf('maxUserPictureHeight', 200), '%size%' => get_conf('maxUserPictureHeight', 100 * 1024)))); }
function user_get_picture_path($userData) { if (!empty($userData['picture'])) { return user_get_private_folder_path($userData['user_id']) . '/' . $userData['picture']; } else { return false; } }