Created
March 6, 2019 06:17
-
-
Save shihabmi7/5ca6de838fc5093e7d655df442c81d52 to your computer and use it in GitHub Desktop.
UploadMultipleGist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function orCefFormSubmit() | |
{ | |
$token = Input::get('token'); | |
$userId = Input::get('user_id'); | |
$tokenValidation = checkToken($userId, $token); | |
if ($tokenValidation) { | |
$filename = null; | |
$psoRow = DB::table('pso_profile') | |
->where('user_id', '=', $userId) | |
->first(); | |
if (Input::file('file')) { | |
$file = Input::file('file'); | |
//$destinationPath = '/home/rxcalcul/public_html/rx_photo/'; | |
$destinationPath = 'C:/xampp/htdocs/vision/rx_photo/'; | |
$filename = time() . $file->getClientOriginalName(); | |
$uploadSuccess = Input::file('file')->move($destinationPath, $filename); | |
$id = DB::table('orcef_rx_data')->insertGetId( | |
array( | |
'n_date' => date('Y-m-d'), | |
'sm' => @$psoRow->sm, | |
'sm_ffc' => @$psoRow->sm_ffc, | |
'rsm' => @$psoRow->rsm, | |
'rsm_ffc' => @$psoRow->rsm_ffc, | |
'dsm' => @$psoRow->dsm, | |
'dsm_ffc' => @$psoRow->dsm_ffc, | |
'pso' => @$psoRow->name, | |
'pso_ffc' => @$psoRow->ffc, | |
'pso_user_id' => $userId, | |
'region' => @$psoRow->region, | |
'head_quarter' => @$psoRow->head_quarter, | |
'depot' => @$psoRow->depot, | |
'team' => @$psoRow->team, | |
) | |
); | |
$image_path = '../rx_photo/'.$filename; | |
DB::table('orcef_rx_data') | |
->where('id', $id) | |
->update( | |
array( | |
'image_name' => $filename, | |
'image_path' => $image_path, | |
) | |
); | |
} | |
$return = array( | |
'status' => 'success', | |
'message' => 'Orcef Rx has been created successfully', | |
'fileUrl' => 'http://renata-vision.xyz/rx_photo/', | |
'token' => $token, | |
); | |
} | |
else { | |
$return = array( | |
'status' => 'failed', | |
'message' => 'Invalid user id or token', | |
'token' => '', | |
); | |
} | |
return response()->json($return); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment