| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/b2c.hellogtx.com/library/Helper/ |
Upload File : |
<?php
/*
* Catabatic Technology Pvt. Ltd.
* File Name :FileUpload.php
* File Description :Helper For Uploading the files
* Created By : Pardeep Panchal
* Created Date: 03-Auguest-2016
*/
class Zend_Controller_Action_Helper_FileUpload extends Zend_Controller_Action_Helper_Abstract
{
public function upload($strDestinationFolder,$strIcon)
{
if(!file_exists($strDestinationFolder)){
mkdir($strDestinationFolder, 0777);
}
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->addFilter('Rename', $strDestinationFolder.$strIcon); // Rename Orignal File ...
$upload->setDestination($strDestinationFolder);
try {
$upload->receive(); // This takes care of the moving and making sure the file is there
} catch (Zend_File_Transfer_Exception $e) {
echo $e->message();
}
}
public function uploadToAWS($data){
$FILES = $data['FILES'];
$AgencySysId = $data['AgencySysId'];
$image_path = $data['image_path'];
$tags = $data['tags'];
$title = $data['title'];
$fileName = $data['fileName'];
$apiData['agency_name'] = $image_path;
$apiData['agency_id'] = $AgencySysId;
$apiData['alt_tags'] = $tags;
$apiData['title'] = $title;
$cfile = new CURLFile($FILES['tmp_name'], $FILES['type'], $fileName);
$apiData['document'] = $cfile;
if(isset($data['TPSysId']) && (int)$data['TPSysId'] > 0){
$apiData['tp_sys_id'] = (int)$data['TPSysId'];
}
if(isset($data['TPPaxSysId']) && (int)$data['TPPaxSysId'] > 0){
$apiData['pax_sys_id'] = (int)$data['TPPaxSysId'];
}
//echo "<pre>";print_r($apiData);die;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://img.hellogtx.com/image-upload/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $apiData,
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
"gtxkey: DFRT5634@GHUYPO123458910RTY",
"postman-token: 05105a87-092d-74ea-3173-e9e167160b99"
),
));
$response = curl_exec($curl);
//echo "<pre>";print_r($response);die;
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return array('status' => false,'message' => "cURL Error #:" . $err);
} else {
return (!empty($response)) ? json_decode($response,1) : '';
}
}
public function getFileFromAWS($data){
$AgencySysId = $data['AgencySysId'];
$folderName = trim($data['folderName']);
$titleName = trim($data['titleName']);
$TPSysId = isset($data['TPSysId']) ? (int)$data['TPSysId'] : 0;
$TPPaxSysId = isset($data['TPPaxSysId']) ? (int)$data['TPPaxSysId'] : 0;
//$folderName = 'doc/'.$AgencySysId.'/vouchers/'.$TPSysId.'/'.$fullVoucherName.'.pdf';
if(!empty($folderName)){
$url111 = "https://img.hellogtx.com/image-upload/?document=$folderName&agency_id=$AgencySysId";
}else if(!empty($titleName)){
$url111 = "https://img.hellogtx.com/image-upload/?title=$titleName&agency_id=$AgencySysId";
}else if($TPSysId > 0 && $TPPaxSysId > 0){
$url111 = "https://img.hellogtx.com/image-upload/?agency_id=$AgencySysId&tp_sys_id=$TPSysId&pax_sys_id=$TPPaxSysId";
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url111,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"gtxkey: DFRT5634@GHUYPO123458910RTY",
"postman-token: cea34a74-6e97-580c-d4fd-c8a20bdbba34"
),
));
$response = curl_exec($curl);
$responseArr = json_decode($response,1);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return array('status' => false,'message' => "cURL Error #:" . $err);
} else {
return $responseArr;
}
}
}