Level 67
in php.ini, post_max_size should be same or greater than upload_max_filesize
i've a form with file input for image and controller, it has been work but no protection added by me, forget about it(I'll add it soon), umm the problem is, it works and can post to DB but for small size file (IDK how big it is) and when i try with image file (4MB) it's error... I've check my PHP.ini and upload_max_filesize = 64M so today i got confuse with this problem, really need ur hand bro, bring it on...
Code of my function on Controller
public function insertkeluhan(Request $request){
if($request->hasFile('ttdcus1')) {
$ttd1Name = $request->file('ttdcus1')->getClientOriginalName();
$path = base_path() . '/public/img/ttd';
$request->file('ttdcus1')->move($path , $ttd1Name);
}
if($request->hasFile('ttdcus2')) {
$ttd2Name = $request->file('ttdcus2')->getClientOriginalName();
$path = base_path() . '/public/img/ttd';
$request->file('ttdcus2')->move($path , $ttd2Name);
}
$keluhan = keluhan::create($request->all());
$keluhan->tanggal = carbon::now();
$keluhan->username;
$keluhan->email_address;
$keluhan->status = 'Pending';
$keluhan->ttd_pemohon = $ttd1Name;
$keluhan->ttd_setuju = $ttd2Name;
$keluhan->save();
return redirect('/');
and here is code of my form
@extends('template')
@section('main')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading"><h4>Keluhan Pelanggan<h4></div>
<div class="panel-body">
<form class="form-horizontal" role="form" method="POST" action="{{ url('/keluhan') }}" enctype="multipart/form-data">
{{ csrf_field() }}
<div>
<input name="username" type="hidden" value="{{$username}}">
<input name="email_address" type="hidden" value="{{$email_address}}">
</div>
<div>
<label for="produk" class="col-md-4 control-label" name="produk">Nama Produk</label>
<div class="col-md-6">
<input id="produk" type="text" class="form-control" name="produk" required="true">
</div>
</div>
<div class="form-group">
<label for="area" class="col-md-4 control-label">Pilih Area</label>
<div class="col-md-6">
<select name="area">
<option value="Jawa Barat">Jawa Barat</option>
<option value="Jawa Tengah">Jawa Tegah</option>
<option value="Jawa Timur">Jawa Timur</option>
<option value="Luar Area Jawa">Luar Area Jawa</option>
</select>
</div>
</div>
<div class="form-group">
<label for="kategori" class="col-md-4 control-label">Kategori</label>
<div class="col-md-6">
<select name="kategori">
<option value="Keluhan Pelanggan">Keluhan Pelanggan</option>
<option value="Survey Pelanggan">Survey Pelanggan</option>
<option value="Inspeksi">Inspeksi</option>
<option value="Audit">Audit</option>
<option value="Gagal Proses">Gagal Proses</option>
<option value="Analisa Data">Analisa Data</option>
</select>
</div>
</div>
<div class="form-group">
<label for="jenis_keluhan" class="col-md-4 control-label">Jenis Keluhan</label>
<div>
<input type="radio" id="priority-low" name="jenis_keluhan" checked value="komplain">
<label for="priority-low">Komplain</label>
<input type="radio" id="priority-normal" name="jenis_keluhan" value="reject">
<label for="priority-normal">Reject</label>
<p></p>
</div>
</div>
<div class="form-group">
<label for="masalah" class="col-md-4 control-label" required="true">Keluhan Anda</label>
<textarea style="resize: none; height: 100px" name="masalah"></textarea>
</div>
<div class="form-group">
<label for="keterangan" class="col-md-4 control-label">Keterangan Tambahan</label>
<textarea style="resize: none; height: 100px" name="keterangan"></textarea><p>
</div>
<div>
<label for="keterangan_tambahan" class="col-md-4 control-label">Tambahkan Gambar</label><p></p>
<input class="field" name="gambarkeluhan" type="file"><p></p>
<div>
<div align="center">
<h5><b>Tanda Tangan</b></h5>
<h7>(Tanda Tangan Berupa Gambar)</h7><p></p>
</div>
<div align="center">
<div>
<h7><b>Pemohon (Customers)</b></h7>
<h7>                            </h7>
<h7><b>Disetujui Oleh (Customers)</b></h7>
</div>
<div>
<input class="field" name="ttdcus1" type="file">
<input class="field" name="ttdcus2" type="file">
<br>
<br>
<br>
<br><br>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4" align="center">
<button type="submit" class="btn btn-primary">
<i class="fa fa-btn fa-sign-in"></i> Lanjut
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<br>
<br>
<br>
<br><br>
@endsection
Here's a good read: http://www.php.net/manual/en/features.file-upload.common-pitfalls.php
Please or to participate in this conversation.