コード例 #1
0
function PhotoUploaded()
{
    $tmp_file = $_FILES['photo']['tmp_name'];
    $content_dir = dirname(__FILE__) . "/ressources/conf/upload";
    if (!is_dir($content_dir)) {
        @mkdir($content_dir);
    }
    if (!@is_uploaded_file($tmp_file)) {
        writelogs("PHOTO: error_unable_to_upload_file", __FUNCTION__, __FILE__, __LINE__);
        $GLOBALS["Photo_error"] = '{error_unable_to_upload_file} ' . $tmp_file;
        return;
    }
    $name_file = $_FILES['photo']['name'];
    if (file_exists($content_dir . "/" . $name_file)) {
        @unlink($content_dir . "/" . $name_file);
    }
    if (!move_uploaded_file($tmp_file, $content_dir . "/" . $name_file)) {
        $GLOBALS["Photo_error"] = "{error_unable_to_move_file} : " . $content_dir . "/" . $name_file;
        writelogs("PHOTO: {error_unable_to_move_file} : " . $content_dir . "/" . $name_file, __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $file = $content_dir . "/" . $name_file;
    writelogs("PHOTO: {$file}", __FUNCTION__, __FILE__, __LINE__);
    $jpegPhoto_datas = file_get_contents($file);
    $ad = new external_ad_search();
    if (!$ad->SaveUserPhoto($jpegPhoto_datas, $_POST["DN"])) {
        $GLOBALS["Photo_error"] = $ad->ldap_error;
        return;
    }
}