mirror of
https://github.com/humhub/humhub.git
synced 2025-01-16 21:58:17 +01:00
Fix: Added unknown upload error if server cancels upload (e.g in case of a post_max_size violation issue)
Enh: Added warning if php max upload/post is less than the humhub setting.
This commit is contained in:
parent
2512807c45
commit
ccfedf00be
@ -4,6 +4,8 @@ HumHub Change Log
|
||||
|
||||
1.2.0-beta.3 under developement
|
||||
--------------------------------
|
||||
- Fix: Added unknown upload error if server cancels upload (e.g in case of a post_max_size violation issue)
|
||||
- Enh: Added warning if php max upload/post is less than the humhub setting.
|
||||
- Enh: Added mp4/ogg blueimp support in post gallery
|
||||
- Enh: Added global (default) notification space settings
|
||||
- Enh: #2359 Use Jplayer playlist feature for post mp3
|
||||
|
@ -192,17 +192,25 @@ class SettingController extends Controller
|
||||
|
||||
// Determine PHP Upload Max FileSize
|
||||
$maxUploadSize = \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('upload_max_filesize'));
|
||||
$fileSizeKey = 'upload_max_filesize';
|
||||
if ($maxUploadSize > \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('post_max_size'))) {
|
||||
$maxUploadSize = \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('post_max_size'));
|
||||
$fileSizeKey = 'post_max_size';
|
||||
}
|
||||
|
||||
$maxUploadSize = floor($maxUploadSize / 1024 / 1024);
|
||||
|
||||
$maxUploadSizeText = "(".$fileSizeKey."): ".$maxUploadSize;
|
||||
|
||||
// Determine currently used ImageLibary
|
||||
$currentImageLibary = 'GD';
|
||||
if (Yii::$app->getModule('file')->settings->get('imageMagickPath'))
|
||||
if (Yii::$app->getModule('file')->settings->get('imageMagickPath')) {
|
||||
$currentImageLibary = 'ImageMagick';
|
||||
}
|
||||
|
||||
return $this->render('file', array('model' => $form, 'maxUploadSize' => $maxUploadSize, 'currentImageLibary' => $currentImageLibary));
|
||||
return $this->render('file', ['model' => $form,
|
||||
'maxUploadSize' => $maxUploadSize,
|
||||
'maxUploadSizeText' => $maxUploadSizeText,
|
||||
'currentImageLibary' => $currentImageLibary]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,9 @@ use humhub\models\Setting;
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'maxFileSize'); ?>
|
||||
<?php echo $form->textField($model, 'maxFileSize', array('class' => 'form-control', 'readonly' => Setting::IsFixed('maxFileSize', 'file'))); ?>
|
||||
<p class="help-block"><?php echo Yii::t('AdminModule.views_setting_file', 'PHP reported a maximum of {maxUploadSize} MB', array('{maxUploadSize}' => $maxUploadSize)); ?></p>
|
||||
<p class="help-block" <?= ($model->maxFileSize > $maxUploadSize) ? 'style="color:'.$this->theme->variable('danger').' !important"' : ''?>>
|
||||
<?= Yii::t('AdminModule.views_setting_file', 'PHP reported a maximum of {maxUploadSize} MB', array('{maxUploadSize}' => $maxUploadSizeText)); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
@ -211,6 +211,11 @@ humhub.module('file', function (module, require, $) {
|
||||
|
||||
Upload.prototype.done = function (e, response) {
|
||||
var that = this;
|
||||
|
||||
if(!response.result.files || !response.result.files.length) {
|
||||
module.log.error('error.unknown', true);
|
||||
}
|
||||
|
||||
$.each(response.result.files, function (index, file) {
|
||||
that.handleFileResponse(file);
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use humhub\modules\file\libs\FileHelper;
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
$object = $this->context->object;
|
||||
?>
|
||||
@ -13,15 +13,15 @@ $object = $this->context->object;
|
||||
<div class="post-files" id="post-files-<?php echo $object->getUniqueId(); ?>">
|
||||
<?php foreach ($files as $file): ?>
|
||||
<?php if ($previewImage->applyFile($file)): ?>
|
||||
<a data-ui-gallery="<?= "gallery-" . $object->getUniqueId(); ?>" href="<?= $file->getUrl(); ?>#.jpeg" title="<?= $file->file_name ?>">
|
||||
<a data-ui-gallery="<?= "gallery-" . $object->getUniqueId(); ?>" href="<?= $file->getUrl(); ?>#.jpeg" title="<?= Html::encode($file->file_name) ?>">
|
||||
<?= $previewImage->render(); ?>
|
||||
</a>
|
||||
<?php elseif(FileHelper::getExtension($file->file_name) == 'mp4'): ?>
|
||||
<a data-ui-gallery="<?= "gallery-" . $object->getUniqueId(); ?>" type="video/mp4" href="<?= $file->getUrl(); ?>#.mp4" title="<?= $file->file_name ?>">
|
||||
<a data-ui-gallery="<?= "gallery-" . $object->getUniqueId(); ?>" type="video/mp4" href="<?= $file->getUrl(); ?>#.mp4" title="<?= Html::encode($file->file_name) ?>">
|
||||
<video src="<?= $file->getUrl() ?>" height="130" />
|
||||
</a>
|
||||
<?php elseif(FileHelper::getExtension($file->file_name) == 'ogv'): ?>
|
||||
<a data-ui-gallery="<?= "gallery-" . $object->getUniqueId(); ?>" type="video/ogg" href="<?= $file->getUrl(); ?>#.ogv" title="<?= $file->file_name ?>">
|
||||
<a data-ui-gallery="<?= "gallery-" . $object->getUniqueId(); ?>" type="video/ogg" href="<?= $file->getUrl(); ?>#.ogv" title="<?= Html::encode($file->file_name) ?>">
|
||||
<video src="<?= $file->getUrl() ?>" height="130" />
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
@ -56,6 +56,9 @@ class CoreJsConfig extends Widget
|
||||
],
|
||||
'text' => [
|
||||
'error.upload' => Yii::t('base', 'Some files could not be uploaded:'),
|
||||
'error.unknown' => Yii::$app->user->isAdmin() ?
|
||||
Yii::t('base', 'An unknown error occured while uploading. Hint: check your upload_max_filesize and post_max_size php settings.')
|
||||
: Yii::t('base', 'An unknown error occured while uploading.'),
|
||||
'success.delete' => Yii::t('base', 'The file has been deleted.')
|
||||
]
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user