ソースを参照

upload pic manual

master
Siti Rahayu 6年前
親
コミット
62fbb29bf8
2個のファイルの変更、51行の追加、0行の削除
  1. 5
    0
      config/routes.yaml
  2. 46
    0
      src/Controller/Api/CompoundController.php

+ 5
- 0
config/routes.yaml ファイルの表示

@@ -8,6 +8,11 @@ api_upload_accaptance_compound:
controller: App\Controller\Api\CompoundController::uploadCompoundAcceptance
methods: POST

api_upload_accaptance_compound:
path: /api/upload/compound/picture/manual
controller: App\Controller\Api\CompoundController::uploadPictureManually
methods: POST

api_upload_investigation_file:
path: /api/upload/investigation/file
controller: App\Controller\Api\InvestigationController::uploadInvestigationFile

+ 46
- 0
src/Controller/Api/CompoundController.php ファイルの表示

@@ -155,6 +155,52 @@ class CompoundController extends Controller{
}
}
public function uploadPictureManually(Request $request)
{
$i = 1; $success_upload = 0; $count_upload = 0;
$filesystem = new Filesystem();
if($request->get('type') == 'staging'){
$destinationPath = 'staging/document/'.$request->get('no_siri').'/compound';
if(!$filesystem->exists('staging/document/'.$request->get('no_siri').'/compound')){
$filesystem->mkdir($destinationPath, 0700);
}
}else if($request->get('type') == 'production'){
$destinationPath = 'production/document/'.$request->get('no_siri').'/compound';
if(!$filesystem->exists('production/document/'.$request->get('no_siri').'/compound')){
$filesystem->mkdir($destinationPath, 0700);
}
}else if($request->get('type') == 'proxy'){
$destinationPath = 'proxy/'.$request->get('no_siri').'/compound';
if(!$filesystem->exists('proxy/'.$request->get('no_siri').'/compound')){
$filesystem->mkdir($destinationPath, 0700);
}
}
$allowedfileExtension = ['jpg','jpeg'];
$destinationPathImage = array();
if($request->files->has('file')){
$count_upload = count($request->files->get('file'));
$urlPackage = new UrlPackage('http://filegoforce.sipadu.my', new EmptyVersionStrategy());
foreach($request->files->get('file') as $f){
$extension = $f->getClientOriginalExtension();
$check=in_array($extension,$allowedfileExtension);
if($check) {
$name = 'manual'.$request->get('kp').'-'.bin2hex(random_bytes(5)).'.'.$f->getClientOriginalExtension();
$destinationPathImage[] = $urlPackage->getUrl('/'.$destinationPath.'/'.$name);
$f->move($destinationPath, $name);
$success_upload++;
}
}
return $this->sendResponse($destinationPathImage, $success_upload.'/'.$count_upload.' berjaya memuatnaik gambar kompaun');
}else{
return $this->sendError('Gagal', 'Gambar kompaun tidak dimuatnaik!');
}
}
public function storeCompoundPDF(Request $request)
{
//Decode Json

読み込み中…
キャンセル
保存