I have a table named "cases
" where the column
are id
image1
,content1
,image2
,content2
,image
3 and content3
My content1,content2,content3
will be saved in database when i submit it from form but images are nither saved in folder nor in database. I need help
Controller
public function store(Request $request,SidContainRequest $request)
{
$sidContain = new sidcontain;
$sidContain->content1 = $request->get('page_content1');
$sidContain->content2 = $request->get('page_content2');
$sidContain->content3 = $request->get('page_content3');
//upload multiple files
$files= [];
if($request->file('leftimage')) $files[] = $request->file('leftimage');
if($request->file('Middleimage')) $files[] = $request->fiel('Middleimage');
if($request->file('Rightimage')) $files[] = $request->file('Rightimage');
foreach($files as $flle)
{
if(!empty($file))
{
$filename[] = $file->getClientOrginalName();
if(isset($filename)){
$file->move(base_path().'/frontend/sidimage/',end($filename));
}
}
$sidContain->image1 = $filename[0];
$sidContain->image2 = $filename[1];
$sidContain->image3 = $filename[2];
}
$ok = $sidContain->save();
if($ok)
{
\Session::flash('flash_message','Report Added Successfully!');
return Redirect::to('administrator/sidConatin/create');
}
}
view/form
<div class="form-group">
<label>Left Image</label>
<input type="file" name="leftimage">
@if($errors->has('leftimage')) <p style="color:red;">{{$errors->first('leftimage')}}</p>@endif
</div>
<div class="form-group">
<label>Left Content</label>
<textarea name="page_content1" id="page_content1" class="editor form-control"></textarea>
@if($errors->has('page_content1'))<p style="color:red;">{{$errors->first('page_content1')}}</p>@endif
</div>
<div class="form-group">
<label>Middle Image</label>
<input type="file" name="Middleimage">
@if($errors->has('Middleimage')) <p style="color:red;">{{$errors->first('Middleimage')}}</p>@endif
</div>
<div class="form-group">
<label>Middle Content</label>
<textarea name="page_content2" id="page_content2" class="editor form-control"></textarea>
@if($errors->has('page_content2')) <p style="color:red;">{{$errors->first('page_content2')}}</p>@endif
</div>
<div class="form-group">
<label>Right Image</label>
<input type="file" name="Rightimage">
@if($errors->has('Rightimage')) <p style="color:red;">{{$errors->first('Rightimage')}}</p>@endif
</div>
<div class="form-group">
<label>Right Content</label>
<textarea name="page_content3" id="page_content3" class="editor form-control"></textarea>
@if($errors->has('page_content3')) <p style="color:red;">{{$errors->first('page_content3')}}</p>@endif
</div>
<div style="margin-top: 15px;">
<button type="submit" class="btn btn-danger">Submit</button>
</div>
</form>
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1UtCc0U
via IFTTT
Aucun commentaire:
Enregistrer un commentaire