upload error plus .user.in

This commit is contained in:
Arno Kaimbacher 2018-11-28 17:06:00 +01:00
parent 559dd4ee10
commit c89f5c6200
8 changed files with 124 additions and 13 deletions

View File

@ -232,16 +232,16 @@ class IndexController extends Controller
'type' => 'required|min:5',
'rights' => 'required|boolean|in:1',
'belongs_to_bibliography' => 'required|boolean',
'title_main.value' => 'required|min:5',
'title_main.value' => 'required|min:4',
'title_main.language' => 'required',
'abstract_main.value' => 'required|min:5',
'abstract_main.value' => 'required|min:4',
'abstract_main.language' => 'required',
];
if (null != $request->file('files')) {
$files = count($request->file('files')) - 1;
foreach (range(0, $files) as $index) {
// $rules['files.' . $index] = 'image|max:2048';
$rules['files.' . $index . '.file'] = ['required', 'file', new RdrFiletypes(), new RdrFilesize()];
$rules['files.' . $index . '.file'] = ['required', 'file', new RdrFiletypes(), new RdrFilesize($index + 1)];
}
}
$validator = Validator::make($request->all(), $rules);

View File

@ -14,9 +14,10 @@ class RdrFilesize implements Rule
*
* @return void
*/
public function __construct()
public function __construct($fileIndex)
{
$this->maxFileSize = Config::get('enums.max_filesize');
$this->fileIndex = $fileIndex;
}
/**
@ -29,7 +30,10 @@ class RdrFilesize implements Rule
public function passes($attribute, $value)
{
//return Rule::in($this->filetypes);
return $this->getSize($attribute, $value) <= $this->maxFileSize;
// $upload_max_size = ini_get('upload_max_filesize');
$fileSize = filesize($value);
return $fileSize <= $this->maxFileSize * 1024;
// return $this->getSize($attribute, $value) <= $this->maxFileSize;
}
/**
@ -39,7 +43,7 @@ class RdrFilesize implements Rule
*/
public function message()
{
return 'file :attribute is too large for the destination storage system.';
return 'file number '. $this->fileIndex .' is too large for the destination storage system.';
}
/**

View File

@ -20,5 +20,5 @@ return [
'filetypes_allowed' => [
"pdf", "txt", "html", "htm", "png", "jpeg",
],
'max_filesize' => '2048',
'max_filesize' => 5120,
];

4
public/.user.ini Normal file
View File

@ -0,0 +1,4 @@
; Override value of upload_max_filesize
upload_max_filesize = 5M
post_max_size =8M
memory_limit = 100M

File diff suppressed because one or more lines are too long

View File

@ -126,6 +126,14 @@ const app = new Vue({
this.dataset.reset();//reset methods will trigger property changed.
this.step = 1;
},
retry() {
// reset form to initial state
this.currentStatus = STATUS_INITIAL;
// this.uploadedFiles = [];
// this.uploadError = null;
// this.dataset.reset();//reset methods will trigger property changed.
// this.step = 1;
},
editNewDataset() {
window.location = this.redirectLink;
},

View File

@ -401,8 +401,11 @@
<div v-if="isFailed">
<h2>Uploaded failed.</h2>
<p>
<a href="javascript:void(0)" @click="reset()">Try again</a>
<a href="javascript:void(0)" @click="retry()">Retry: Edit inputs</a>
</p>
<p>
<a href="javascript:void(0)" @click="reset()">Start again</a>
</p>
<div v-if="serrors.length > 0">
<b>Please correct the following server error(s):</b>
<ul class="alert validation-summary-errors">

View File

@ -1,5 +1,87 @@
@extends('settings.layouts.app')
@section('styles')
<style type="text/css" media="screen">
.php-info pre {
margin: 0;
font-family: monospace;
}
.php-info a:link {
color: #009;
text-decoration: none;
background-color: #ffffff;
}
.php-info a:hover {
text-decoration: underline;
}
.php-info table {
border-collapse: collapse;
border: 0;
width: 100%;
box-shadow: 1px 2px 3px #ccc;
}
.php-info .center {
text-align: center;
}
.php-info .center table {
margin: 1em auto;
text-align: left;
}
.php-info .center th {
text-align: center !important;
}
.php-info td {
border: 1px solid #666;
font-size: 75%;
vertical-align: baseline;
padding: 4px 5px;
}
.php-info th {
border: 1px solid #666;
font-size: 75%;
vertical-align: baseline;
padding: 4px 5px;
}
.php-info h1 {
font-size: 150%;
}
.php-info h2 {
font-size: 125%;
}
.php-info .p {
text-align: left;
}
.php-info .e {
background-color: #ccf;
width: 50px;
font-weight: bold;
}
.php-info .h {
background-color: #99c;
font-weight: bold;
}
.php-info .v {
background-color: #ddd;
max-width: 50px;
overflow-x: auto;
word-wrap: break-word;
}
.php-info .v i {
color: #999;
}
.php-info img {
float: right;
border: 0;
}
.php-info hr {
width: 100%;
background-color: #ccc;
border: 0;
height: 1px;
}
</style>
@endsection
{{-- @section('breadcrumbs', Breadcrumbs::render('settings.dashboard')) --}}
@section('content')
@ -8,7 +90,17 @@
</div>
<div class="pure-g box-content">
<div class="pure-u-1 pure-u-md-2-3">
<canvas id="myChart" width="400" height="260"></canvas>
{{-- <canvas id="myChart" width="400" height="260"></canvas> --}}
<div class="php-info">
@php
ob_start();
phpinfo();
$pinfo = ob_get_contents();
ob_end_clean();
$pinfo = preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1',$pinfo);
echo $pinfo;
@endphp
</div>
</div>
</div>
@ -43,8 +135,8 @@
@section('after-scripts')
<!-- <script src="bower_components/chart.js/dist/Chart.min.js"></script> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.2.1/Chart.min.js"></script>
<script>
{{-- <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.2.1/Chart.min.js"></script> --}}
{{-- <script>
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'bar',
@ -82,5 +174,5 @@
}
}
});
</script>
</script> --}}
@endsection