I followed a couple of tutorial about batch image upload using laravel but they all talk about displaying images as thumbnails which it is not what i want to achieve. this is part of the controller
class Jan2017Controller extends Controller {
//index
public function index() {
$jan2017 = JAN2017::all();
return view('pages.jan2017', compact('jan2017'));
}
//uploading images to DB
public function upload() {
// getting all of the post data
//$file = array('image' => Request::file('image'));
$file = Input::file('images');
//counting all selected images
$file_count = count($file);
$uploadcount = 0;
// setting up rules
foreach($file as $file) {
$rules = array('form' => 'required'); //mimes:jpeg,bmp,png and for max size max:10000
// doing the validation, passing post data, rules and the messages
$validator = Validator::make(array ('form'=>$file), $rules);
if ($validator->passes())
{
$destinationPath = 'uploads';
$filename = $file->getClientOriginalName();
$upload_success = $file->move($destinationPath, $filename);
$uploadcount ++;
$extension = $file->getClientOriginalExtension();
$entry = new JAN2017;
$entry->format = $file->getClientMimeType();
$entry->filename = $filename;
$entry->save();
}
}
if($uploadcount == $file_count)
{
Session::flash('message', 'Uploaded successfully');
return Redirect::to('jan2017');
}
else {
return Redirect::to('jan2017')->withInput()->withErrors($validator);
}
}
I have a table that display image names stored in db and now i want a corresponding image to pop up/show when a user clicks on its filename.
//rendering tabular view
@include('settings.delete_modal')
@extends('layouts.app')
@section('content')
<div class="page_content">
<caption>
<div class="secure">Click to select forms</div>
{!! Form::open(array('url'=>'jan2017/upload','method'=>'POST', 'files'=>true)) !!}
{!! Form::file('images[]', array('multiple'=>true)) !!}
<p>{!!$errors->first('images')!!}</p>
@if(Session::has('error'))
<p>{!! Session::get('error') !!}</p>
@endif
{!! Form::submit('Archive', array('class'=>'btn btn-info')) !!}
{!! Form::close() !!}
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
@if(Session::has('success'))
<div class="alert-box success">
<h2>{!! Session::get('success') !!}</h2>
</div>
@endif
<br></br>
<div class="row">
<div class="col-md-12">
<span style="font-size:25px"> January 2017 Images</span><br>
<div class="panel panel-primary">
<table class="custom-data-table table table-striped dataTable no-footer display nowrap" id="jan2017" data-form="deleteForm">
<thead>
<tr>
<th >#</th>
<th >Image Name</th>
<th >File Format</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $row=1; ?>
@foreach( $jan2017 as $jan2017)
<tr>
<th> </th>
<td class="text-left"><img src=''></td>
<td class="text-left"></td>
<td>
<div class="btn-group">
</div>
</td>
</tr>
<?php $row++; ?>
@endforeach
</tbody>
</table>
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
Anyone out there who can help? Thanks in advance
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2AGIhVL
via IFTTT
Aucun commentaire:
Enregistrer un commentaire