當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Functions::fileUploadErrorText方法代碼示例

本文整理匯總了PHP中Fisharebest\Webtrees\Functions\Functions::fileUploadErrorText方法的典型用法代碼示例。如果您正苦於以下問題:PHP Functions::fileUploadErrorText方法的具體用法?PHP Functions::fileUploadErrorText怎麽用?PHP Functions::fileUploadErrorText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Fisharebest\Webtrees\Functions\Functions的用法示例。


在下文中一共展示了Functions::fileUploadErrorText方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1:

     FlashMessages::addMessage(I18N::translate('No media file was provided.'));
     break;
 } else {
     $fileName = $filename;
 }
 // Now copy the file to the correct location.
 if (!empty($_FILES['mediafile']['name'])) {
     $serverFileName = WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName . $fileName;
     if (file_exists($serverFileName)) {
         FlashMessages::addMessage(I18N::translate('The file %s already exists. Use another filename.', $folderName . $fileName));
         break;
     }
     if (move_uploaded_file($_FILES['mediafile']['tmp_name'], $serverFileName)) {
         Log::addMediaLog('Media file ' . $serverFileName . ' uploaded');
     } else {
         FlashMessages::addMessage(I18N::translate('There was an error uploading your file.') . '<br>' . Functions::fileUploadErrorText($_FILES['mediafile']['error']));
         break;
     }
     // Now copy the (optional) thumbnail
     if (!empty($_FILES['thumbnail']['name']) && preg_match('/^image\\/(png|gif|jpeg)/', $_FILES['thumbnail']['type'], $match)) {
         // Thumbnails have either
         // (a) the same filename as the main image
         // (b) the same filename as the main image - but with a .png extension
         if ($match[1] == 'png' && !preg_match('/\\.(png)$/i', $fileName)) {
             $thumbFile = preg_replace('/\\.[a-z0-9]{3,5}$/', '.png', $fileName);
         } else {
             $thumbFile = $fileName;
         }
         $serverFileName = WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName . $thumbFile;
         if (move_uploaded_file($_FILES['thumbnail']['tmp_name'], $serverFileName)) {
             Log::addMediaLog('Thumbnail file ' . $serverFileName . ' uploaded');
開發者ID:pal-saugstad,項目名稱:webtrees,代碼行數:31,代碼來源:addmedia.php

示例2: header

     return;
 case 'replace_upload':
     $gedcom_id = Filter::postInteger('gedcom_id');
     $keep_media = Filter::post('keep_media', '1', '0');
     $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH');
     $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0');
     $tree = Tree::findById($gedcom_id);
     if (Filter::checkCsrf() && $tree) {
         $tree->setPreference('keep_media', $keep_media);
         $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH);
         $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES);
         if (isset($_FILES['tree_name'])) {
             if ($_FILES['tree_name']['error'] == 0 && is_readable($_FILES['tree_name']['tmp_name'])) {
                 $tree->importGedcomFile($_FILES['tree_name']['tmp_name'], $_FILES['tree_name']['name']);
             } else {
                 FlashMessages::addMessage(Functions::fileUploadErrorText($_FILES['tree_name']['error']), 'danger');
             }
         } else {
             FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger');
         }
     }
     header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
     return;
 case 'replace_import':
     $basename = basename(Filter::post('tree_name'));
     $gedcom_id = Filter::postInteger('gedcom_id');
     $keep_media = Filter::post('keep_media', '1', '0');
     $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH');
     $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0');
     $tree = Tree::findById($gedcom_id);
     if (Filter::checkCsrf() && $tree) {
開發者ID:tronsmit,項目名稱:webtrees,代碼行數:31,代碼來源:admin_trees_manage.php


注:本文中的Fisharebest\Webtrees\Functions\Functions::fileUploadErrorText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。