Upload dir, Upload contoller, view images

This commit is contained in:
2021-01-30 15:25:47 +01:00
parent 8fce0013f7
commit a494bf208f
3 changed files with 39 additions and 35 deletions

1
.gitignore vendored
View File

@@ -1,6 +1,7 @@
/node_modules /node_modules
/public/hot /public/hot
/public/storage /public/storage
/public/upload/*
/storage/*.key /storage/*.key
/vendor /vendor
.env .env

View File

@@ -9,49 +9,49 @@ class Upload extends Controller
public function index(){ public function index(){
return view('index'); return view('index');
} }
public function uploadFile(Request $request){ public function uploadFile(Request $request){
if ($request->input('submit') != null ){ if ($request->input('submit') != null ){
$file = $request->file('file'); $file = $request->file('file');
// File Details // File Details
$filename = $file->getClientOriginalName(); $filename = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension(); $extension = $file->getClientOriginalExtension();
$tempPath = $file->getRealPath(); $tempPath = $file->getRealPath();
$fileSize = $file->getSize(); $fileSize = $file->getSize();
$mimeType = $file->getMimeType(); $mimeType = $file->getMimeType();
// Valid File Extensions // Valid File Extensions
$valid_extension = array("jpg","jpeg","png"); $valid_extension = array("jpg","jpeg","png");
// 2MB in Bytes // 2MB in Bytes
$maxFileSize = 2097152; $maxFileSize = 2097152;
// Check file extension // Check file extension
if(in_array(strtolower($extension),$valid_extension)){ if(in_array(strtolower($extension),$valid_extension)){
// Check file size // Check file size
if($fileSize <= $maxFileSize){ if($fileSize <= $maxFileSize){
// File upload location // File upload location
$location = 'images'; $location = 'upload/images';
// Upload file // Upload file
$file->move($location,$filename); $file->move($location,$filename);
Session::flash('message','Upload Successful.'); echo 'Upload Successful.';
}else{ }else{
Session::flash('message','File too large. File must be less than 2MB.'); echo 'File too large. File must be less than 2MB.';
} }
}else{ }else{
Session::flash('message','Invalid File Extension.'); echo 'message Invalid File Extension.';
} }
} }
// Redirect to index // Redirect to index
echo "OK"; echo "OK";
} }

View File

@@ -62,7 +62,7 @@
} }
</style> </style>
<script src="{{ asset('js/app.js') }}" defer></script> <script src="{{ asset('js/app.js') }}" defer></script>
<link href="{{ asset('css/app.css') }}" rel="stylesheet"> <link href="{{ asset('css/app.css') }}" rel="stylesheet">
@@ -87,7 +87,7 @@
<div class="title m-b-md"> <div class="title m-b-md">
Teplomer balkón Teplomer balkón
</div> </div>
<div id="app"> <div id="app">
<div class="row"> <div class="row">
<vue-thermometer class="justify-content-center col-sm-3" :value="temperature" :min="tmin" :max="tmax"></vue-thermometer> <vue-thermometer class="justify-content-center col-sm-3" :value="temperature" :min="tmin" :max="tmax"></vue-thermometer>
@@ -105,13 +105,13 @@
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
<div class='input-group time' id='datetimepicker1'> <div class='input-group time' id='datetimepicker1'>
<datetime type="datetime" input-class="form-control" placeholder="Od" v-model="startdate"></datetime> <datetime type="datetime" input-class="form-control" placeholder="Od" v-model="startdate"></datetime>
<span class="input-group-append"> <span class="input-group-append">
<span class="input-group-text"><i class="fa fa-calendar"></i></span> <span class="input-group-text"><i class="fa fa-calendar"></i></span>
</span> </span>
</div> </div>
</div> </div>
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
<div class='input-group time' id='datetimepicker2'> <div class='input-group time' id='datetimepicker2'>
<datetime type="datetime" input-class="form-control" placeholder="Do" v-model="enddate"></datetime> <datetime type="datetime" input-class="form-control" placeholder="Do" v-model="enddate"></datetime>
@@ -120,7 +120,7 @@
</span> </span>
<span class="input-group-append"> <span class="input-group-append">
<button v-on:click="displayResults()" type="button" class="btn btn-secondary">Zobraz</button> <button v-on:click="displayResults()" type="button" class="btn btn-secondary">Zobraz</button>
</span> </span>
</div> </div>
</div> </div>
</div> </div>
@@ -128,7 +128,7 @@
</div> </div>
<b-card no-body> <b-card no-body>
<b-tabs v-model="ti" card lazy> <b-tabs v-model="ti" card lazy>
<b-tab title="Teplota" @click="resizeGraph(0)"> <b-tab title="Teplota" @click="resizeGraph(0)">
<dygraphs ref="dg[0]" :graph-data="series['temperature']" :graph-options="options['temperature']"></dygraphs> <dygraphs ref="dg[0]" :graph-data="series['temperature']" :graph-options="options['temperature']"></dygraphs>
<br/> <br/>
<!-- Tabs with card integration --> <!-- Tabs with card integration -->
@@ -139,10 +139,10 @@
<stats-table :fromdate="startdate" :todate="enddate" :type="'temperature'" :key="componentKey"></stats-table> <stats-table :fromdate="startdate" :todate="enddate" :type="'temperature'" :key="componentKey"></stats-table>
</b-tab> </b-tab>
<b-tab title="Hodina"> <b-tab title="Hodina">
<stats-table :fromdate="startdate" :todate="enddate" :type="'temperature'" :range="'1h'" :key="componentKey"></stats-table> <stats-table :fromdate="startdate" :todate="enddate" :type="'temperature'" :range="'1h'" :key="componentKey"></stats-table>
</b-tab> </b-tab>
<b-tab title="Deň" v-if="startdate"> <b-tab title="Deň" v-if="startdate">
<stats-table :fromdate="startdate" :todate="enddate" :type="'temperature'" :range="'1d'" :key="componentKey"></stats-table> <stats-table :fromdate="startdate" :todate="enddate" :type="'temperature'" :range="'1d'" :key="componentKey"></stats-table>
</b-tab> </b-tab>
</b-tabs> </b-tabs>
</b-card> </b-card>
@@ -156,10 +156,10 @@
<stats-table :fromdate="startdate" :todate="enddate" :type="'humidity'" :key="componentKey"></stats-table> <stats-table :fromdate="startdate" :todate="enddate" :type="'humidity'" :key="componentKey"></stats-table>
</b-tab> </b-tab>
<b-tab title="Hodina"> <b-tab title="Hodina">
<stats-table :fromdate="startdate" :todate="enddate" :type="'humidity'" :range="'1h'" :key="componentKey"></stats-table> <stats-table :fromdate="startdate" :todate="enddate" :type="'humidity'" :range="'1h'" :key="componentKey"></stats-table>
</b-tab> </b-tab>
<b-tab title="Deň" v-if="startdate"> <b-tab title="Deň" v-if="startdate">
<stats-table :fromdate="startdate" :todate="enddate" :type="'humidity'" :range="'1d'" :key="componentKey"></stats-table> <stats-table :fromdate="startdate" :todate="enddate" :type="'humidity'" :range="'1d'" :key="componentKey"></stats-table>
</b-tab> </b-tab>
</b-tabs> </b-tabs>
</b-card> </b-card>
@@ -173,23 +173,26 @@
<stats-table :fromdate="startdate" :todate="enddate" :type="'pressure'" :key="componentKey"></stats-table> <stats-table :fromdate="startdate" :todate="enddate" :type="'pressure'" :key="componentKey"></stats-table>
</b-tab> </b-tab>
<b-tab title="Hodina"> <b-tab title="Hodina">
<stats-table :fromdate="startdate" :todate="enddate" :type="'pressure'" :range="'1h'" :key="componentKey"></stats-table> <stats-table :fromdate="startdate" :todate="enddate" :type="'pressure'" :range="'1h'" :key="componentKey"></stats-table>
</b-tab> </b-tab>
<b-tab title="Deň" v-if="startdate"> <b-tab title="Deň" v-if="startdate">
<stats-table :fromdate="startdate" :todate="enddate" :type="'pressure'" :range="'1d'" :key="componentKey"></stats-table> <stats-table :fromdate="startdate" :todate="enddate" :type="'pressure'" :range="'1d'" :key="componentKey"></stats-table>
</b-tab> </b-tab>
</b-tabs> </b-tabs>
</b-card> </b-card>
</b-tab> </b-tab>
</b-tabs> </b-tabs>
</b-card> </b-card>
</div> <div v-if="host == 'strecha'">
<img src="{{ url('upload/images/camera.jpg') }}" alt="" title="" />
</div>
</div>
</div> </div>
</div> </div>
<script> <script>
</script> </script>
</body> </body>
</html> </html>