Fix upload issue. allow po to upload multiple and display multiple. Display download link when the uploaded file is not image

This commit is contained in:
weiweitoo
2018-07-19 17:45:25 +08:00
parent 6e849b6145
commit 16205404e1
14 changed files with 212 additions and 83 deletions
@@ -15,30 +15,29 @@ class ChinaBankSlipController extends Controller
{
$booking = Booking::where('id',$id)->firstOrFail();
if (!$booking) {
return response()->json(['message'=>'Access denied'], 403);
}
// TODO : put this after check file exist
// validate file format
$validator = Validator::make($request->all(), [
'file' => 'image|mimes:jpg,jpeg,bmp,png'
'file' => 'mimes:jpg,jpeg,bmp,png,xls,xlsx,doc,docx,pdf'
]);
if($validator->fails())
{
return response()->json(['message'=>'Incorrect format'],200);
if($validator->fails()){
return response()->json(['message'=>'Incorrect format'],400);
}
$validator = Validator::make($request->all(), [
'china_bank_slips' => 'max:3072'
]);
if($validator->fails())
{
if($validator->fails()){
return response()->json(['message'=>'Image too large, upload files up to 3 MB'], 400);
}
if($bankslip_file = $request->file('file')){
$filename = $bankslip_file->getClientOriginalName();
$ext = $bankslip_file->getClientOriginalExtension();
$unique_name = 'cnbank_slip_' . md5($filename. time()); // probably not a good idea