当前位置: 首页>>代码示例>>PHP>>正文


PHP Upload::get_error方法代码示例

本文整理汇总了PHP中Upload::get_error方法的典型用法代码示例。如果您正苦于以下问题:PHP Upload::get_error方法的具体用法?PHP Upload::get_error怎么用?PHP Upload::get_error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Upload的用法示例。


在下文中一共展示了Upload::get_error方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upload_smiley

 private function upload_smiley()
 {
     $folder_phpboost_smileys = $this->smileys_path;
     if (!is_writable($folder_phpboost_smileys)) {
         $is_writable = @chmod($folder_phpboost_smileys, 0777);
     } else {
         $is_writable = true;
     }
     if ($is_writable) {
         $uploaded_file = $this->upload_form->get_value('file');
         if ($uploaded_file !== null) {
             $authorized_pictures_extensions = FileUploadConfig::load()->get_authorized_picture_extensions();
             if (empty($authorized_pictures_extensions)) {
                 $this->view->put('MSG', MessageHelper::display(LangLoader::get_message('e_upload_invalid_format', 'errors'), MessageHelper::NOTICE));
             }
             $upload = new Upload($this->smileys_path);
             if ($upload->file('upload_smiley_file', '`([a-z0-9()_-])+\\.(' . implode('|', array_map('preg_quote', $authorized_pictures_extensions)) . ')+$`i')) {
                 // TODO : gérer les archives de smileys (possibilité d'uploader un zip + case à cocher si on veut créer directement chaque smiley avec :nom_du_smiley comme code)
             } else {
                 $this->view->put('MSG', MessageHelper::display(LangLoader::get_message($upload->get_error(), 'errors'), MessageHelper::NOTICE));
             }
         } else {
             $this->view->put('MSG', MessageHelper::display(LangLoader::get_message('process.error', 'status-messages-common'), MessageHelper::NOTICE));
         }
     } else {
         $this->view->put('MSG', MessageHelper::display(LangLoader::get_message('e_upload_failed_unwritable', 'errors'), MessageHelper::WARNING));
     }
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:28,代码来源:AdminSmileysFormController.class.php

示例2: elseif

    }
} elseif (!empty($_FILES['upload_ranks']['name'])) {
    //Si le dossier n'est pas en écriture on tente un CHMOD 777
    @clearstatcache();
    $dir = PATH_TO_ROOT . '/forum/templates/images/ranks/';
    if (!is_writable($dir)) {
        $is_writable = @chmod($dir, 0777) ? true : false;
    }
    $error = '';
    if (is_writable($dir)) {
        $authorized_pictures_extensions = FileUploadConfig::load()->get_authorized_picture_extensions();
        if (!empty($authorized_pictures_extensions)) {
            $Upload = new Upload($dir);
            $Upload->disableContentCheck();
            if (!$Upload->file('upload_ranks', '`([a-z0-9_ -])+\\.(' . implode('|', array_map('preg_quote', $authorized_pictures_extensions)) . ')+$`i')) {
                $error = $Upload->get_error();
            }
        } else {
            $error = 'e_upload_invalid_format';
        }
    } else {
        $error = 'e_upload_failed_unwritable';
    }
    $error = !empty($error) ? '?error=' . $error : '';
    AppContext::get_response()->redirect(HOST . SCRIPT . $error);
} else {
    $template = new FileTemplate('forum/admin_ranks_add.tpl');
    //Gestion erreur.
    $get_error = retrieve(GET, 'error', '');
    $array_error = array('e_upload_invalid_format', 'e_upload_max_weight', 'e_upload_error', 'e_upload_php_code', 'e_upload_failed_unwritable');
    if (in_array($get_error, $array_error)) {
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:31,代码来源:admin_ranks_add.php

示例3: url

     DispatchManager::redirect($error_controller);
 }
 //Niveau d'autorisation de la catégorie, accès en écriture.
 if (!$Gallery->auth_upload_pics(AppContext::get_current_user()->get_id(), AppContext::get_current_user()->get_level())) {
     AppContext::get_response()->redirect('/gallery/gallery' . url('.php?add=1&cat=' . $id_category . '&error=upload_limit', '-' . $id_category . '.php?add=1&error=upload_limit', '&') . '#message_helper');
 }
 $dir = 'pics/';
 $authorized_pictures_extensions = FileUploadConfig::load()->get_authorized_picture_extensions();
 $error = '';
 if (!empty($authorized_pictures_extensions)) {
     $Upload = new Upload($dir);
     $idpic = 0;
     $idcat_post = retrieve(POST, 'cat', '');
     $name_post = retrieve(POST, 'name', '', TSTRING_AS_RECEIVED);
     if (!$Upload->file('gallery', '`([a-z0-9()_-])+\\.(' . implode('|', array_map('preg_quote', $authorized_pictures_extensions)) . ')+$`i', Upload::UNIQ_NAME, $config->get_max_weight())) {
         $error = $Upload->get_error();
     }
 } else {
     $error = 'e_upload_invalid_format';
 }
 if ($error != '') {
     AppContext::get_response()->redirect(GalleryUrlBuilder::get_link_cat_add($id_category, $error) . '#message_helper');
 } else {
     $path = $dir . $Upload->get_filename();
     $error = $Upload->check_img($config->get_max_width(), $config->get_max_height(), Upload::DELETE_ON_ERROR);
     if (!empty($error)) {
         //Erreur, on arrête ici
         AppContext::get_response()->redirect(GalleryUrlBuilder::get_link_cat_add($id_category, $error) . '#message_helper');
     } else {
         //Enregistrement de l'image dans la bdd.
         $Gallery->Resize_pics($path);
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:31,代码来源:gallery.php

示例4: Upload

 $member_memory_used = Uploads::Member_memory_used(AppContext::get_current_user()->get_id());
 if ($member_memory_used >= $group_limit && !$unlimited_data) {
     $error = 'e_max_data_reach';
 } else {
     //Si le dossier n'est pas en écriture on tente un CHMOD 777
     @clearstatcache();
     $dir = PATH_TO_ROOT . '/upload/';
     if (!is_writable($dir)) {
         $is_writable = @chmod($dir, 0777);
     }
     @clearstatcache();
     if (is_writable($dir)) {
         $weight_max = $unlimited_data ? 100000000 : $group_limit - $member_memory_used;
         $Upload = new Upload($dir);
         $Upload->file('upload_file', '`([a-z0-9()_-])+\\.(' . implode('|', array_map('preg_quote', $files_upload_config->get_authorized_extensions())) . ')+$`i', Upload::UNIQ_NAME, $weight_max);
         if ($Upload->get_error() != '') {
             $error = $Upload->get_error();
             if ($Upload->get_error() == 'e_upload_max_weight') {
                 $error = 'e_max_data_reach';
             }
             AppContext::get_response()->redirect('/user/upload.php?f=' . $folder . '&erroru=' . $error . '&' . $popup_noamp . '#message_helper');
         } else {
             $result = PersistenceContext::get_querier()->insert(DB_TABLE_UPLOAD, array('idcat' => $folder, 'name' => $Upload->get_original_filename(), 'path' => $Upload->get_filename(), 'user_id' => AppContext::get_current_user()->get_id(), 'size' => $Upload->get_human_readable_size(), 'type' => $Upload->get_extension(), 'timestamp' => time()));
             $id_file = $result->get_last_inserted_id();
         }
     } else {
         $error = 'e_upload_failed_unwritable';
     }
 }
 $anchor = !empty($error) ? '&error=' . $error . '&' . $popup_noamp . '#message_helper' : '&' . $popup_noamp . (!empty($id_file) ? '#fi1' . $id_file : '');
 AppContext::get_response()->redirect(HOST . DIR . url('/user/upload.php?f=' . $folder . $anchor, '', '&'));
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:31,代码来源:upload.php

示例5: upload_avatar

 private function upload_avatar($form, $member_extended_field)
 {
     $avatar = $form->get_value('upload_avatar');
     $user_accounts_config = UserAccountsConfig::load();
     $authorized_pictures_extensions = FileUploadConfig::load()->get_authorized_picture_extensions();
     if (empty($authorized_pictures_extensions)) {
         return new MemberExtendedFieldErrorsMessageException(LangLoader::get_message('e_upload_invalid_format', 'errors'));
     }
     if ($form->get_value('link_avatar')) {
         if (preg_match('`([A-Za-z0-9()_-])+\\.(' . implode('|', array_map('preg_quote', $authorized_pictures_extensions)) . ')+$`i', $form->get_value('link_avatar'))) {
             $image = new Image($form->get_value('link_avatar'));
             if ($image->get_width() > $user_accounts_config->get_max_avatar_width() || $image->get_height() > $user_accounts_config->get_max_avatar_height()) {
                 if ($user_accounts_config->is_avatar_auto_resizing_enabled()) {
                     $directory = '/images/avatars/' . Url::encode_rewrite($image->get_name() . '_' . $this->key_hash()) . '.' . $image->get_extension();
                     $resizer = new ImageResizer();
                     $resizer->resize_with_max_values($image, $user_accounts_config->get_max_avatar_width(), $user_accounts_config->get_max_avatar_height(), PATH_TO_ROOT . $directory);
                     $this->delete_old_avatar($member_extended_field);
                     return $directory;
                 }
                 throw new MemberExtendedFieldErrorsMessageException(LangLoader::get_message('e_upload_max_dimension', 'errors'));
             }
             $this->delete_old_avatar($member_extended_field);
             return $form->get_value('link_avatar');
         } else {
             throw new MemberExtendedFieldErrorsMessageException(LangLoader::get_message('e_upload_invalid_format', 'errors'));
         }
     } elseif (!empty($avatar)) {
         if (UserAccountsConfig::load()->is_avatar_upload_enabled()) {
             $dir = '/images/avatars/';
             if ($user_accounts_config->is_avatar_auto_resizing_enabled()) {
                 $image = new Image($avatar->get_temporary_filename());
                 $resizer = new ImageResizer();
                 $explode = explode('.', $avatar->get_name());
                 $extension = array_pop($explode);
                 if (!in_array($extension, $authorized_pictures_extensions)) {
                     return new MemberExtendedFieldErrorsMessageException(LangLoader::get_message('e_upload_invalid_format', 'errors'));
                 }
                 $explode = explode('.', $avatar->get_name());
                 $name = $explode[0];
                 $directory = $dir . Url::encode_rewrite($name . '_' . $this->key_hash()) . '.' . $extension;
                 try {
                     $resizer->resize_with_max_values($image, $user_accounts_config->get_max_avatar_width(), $user_accounts_config->get_max_avatar_height(), PATH_TO_ROOT . $directory);
                     $this->delete_old_avatar($member_extended_field);
                     return $directory;
                 } catch (UnsupportedOperationException $e) {
                     throw new MemberExtendedFieldErrorsMessageException(LangLoader::get_message('e_upload_invalid_format', 'errors'));
                 }
             } else {
                 $Upload = new Upload(PATH_TO_ROOT . $dir);
                 $Upload->file($form->get_html_id() . '_upload_avatar', '`([A-Za-z0-9()_-])+\\.(' . implode('|', array_map('preg_quote', $authorized_pictures_extensions)) . ')+$`i', Upload::UNIQ_NAME, $user_accounts_config->get_max_avatar_weight() * 1024);
                 $upload_error = $Upload->get_error();
                 if (!empty($upload_error)) {
                     throw new MemberExtendedFieldErrorsMessageException(LangLoader::get_message($upload_error, 'errors'));
                 }
                 $error = $Upload->check_img($user_accounts_config->get_max_avatar_width(), $user_accounts_config->get_max_avatar_height(), Upload::DELETE_ON_ERROR);
                 if (!empty($error)) {
                     throw new MemberExtendedFieldErrorsMessageException(LangLoader::get_message($error, 'errors'));
                 } else {
                     $this->delete_old_avatar($member_extended_field);
                     return $dir . $Upload->get_filename();
                 }
             }
         }
     } else {
         return MemberExtendedFieldsService::return_field_member($member_extended_field->get_field_name(), $member_extended_field->get_user_id());
     }
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:67,代码来源:MemberUserAvatarExtendedField.class.php

示例6: elseif

} elseif ($home_folder) {
    //Retour à la racine.
    AppContext::get_response()->redirect('/admin/admin_files.php');
} elseif (!empty($_FILES['upload_file']['name']) && $folder) {
    //Si le dossier n'est pas en écriture on tente un CHMOD 777
    @clearstatcache();
    $dir = PATH_TO_ROOT . '/upload/';
    if (!is_writable($dir)) {
        $is_writable = @chmod($dir, 0777);
    }
    @clearstatcache();
    $error = '';
    if (is_writable($dir)) {
        $Upload = new Upload($dir);
        $Upload->file('upload_file', '`([a-z0-9()_-])+\\.(' . implode('|', array_map('preg_quote', FileUploadConfig::load()->get_authorized_extensions())) . ')+$`i', Upload::UNIQ_NAME);
        if ($Upload->get_error() != '') {
            //Erreur, on arrête ici
            AppContext::get_response()->redirect('/admin/admin_files.php?f=' . $folder . '&erroru=' . $Upload->get_error() . '#message_helper');
        } else {
            $check_user_folder = 0;
            try {
                $check_user_folder = PersistenceContext::get_querier()->get_column_value(DB_TABLE_UPLOAD_CAT, 'user_id', 'WHERE id=:id', array('id' => $folder));
            } catch (RowNotFoundException $e) {
            }
            $user_id = $check_user_folder <= 0 ? -1 : AppContext::get_current_user()->get_id();
            $user_id = max($user_id, $folder_member);
            $result = PersistenceContext::get_querier()->insert(DB_TABLE_UPLOAD, array('idcat' => $folder, 'name' => $Upload->get_original_filename(), 'path' => $Upload->get_filename(), 'user_id' => $user_id, 'size' => $Upload->get_human_readable_size(), 'type' => $Upload->get_extension(), 'timestamp' => time()));
            $id_file = $result->get_last_inserted_id();
        }
    } else {
        $error = 'e_upload_failed_unwritable';
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:31,代码来源:admin_files.php


注:本文中的Upload::get_error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。