mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-26 07:44:15 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user