file upload issue handled : GWM
This commit is contained in:
parent
5211627ebb
commit
28d793fd97
3
.gitignore
vendored
3
.gitignore
vendored
@ -16,3 +16,6 @@
|
||||
/writable/uploads/passport/*
|
||||
/writable/uploads/signature/*
|
||||
/writable/uploads/template/*
|
||||
|
||||
|
||||
/public/assets/images/signature/*
|
||||
|
||||
@ -636,7 +636,8 @@ class MasterController extends ResourceController
|
||||
$file = $this->request->getFile('signature');
|
||||
if ($file && $file->isValid() && !$file->hasMoved()) {
|
||||
$newName = $file->getRandomName(); // Generate a unique name
|
||||
$uploadPath = WRITEPATH.'uploads/signature';
|
||||
// $uploadPath = WRITEPATH.'uploads/signature';
|
||||
$uploadPath = FCPATH.'public/assets/images/signature';
|
||||
|
||||
// print_r( $uploadPath); die;
|
||||
|
||||
@ -651,7 +652,7 @@ class MasterController extends ResourceController
|
||||
|
||||
try {
|
||||
|
||||
$this->mailTemplateModel->set(['image_location' => $path])->where('template_name','forex')->update();
|
||||
$this->mailTemplateModel->set(['image_location' => $newName])->where('template_name','forex')->update();
|
||||
|
||||
|
||||
return $this->respondCreated([
|
||||
@ -664,19 +665,50 @@ class MasterController extends ResourceController
|
||||
}
|
||||
}
|
||||
|
||||
// public function getForexSignaturePath()
|
||||
// {
|
||||
|
||||
// $data = $this->mailTemplateModel->where('template_name','forex')->first();
|
||||
|
||||
// return $this->respond([
|
||||
// 'status' => 200,
|
||||
// 'message' => 'success',
|
||||
// 'data' => $data
|
||||
|
||||
// ]);
|
||||
|
||||
// }
|
||||
|
||||
public function getForexSignaturePath()
|
||||
{
|
||||
|
||||
$data = $this->mailTemplateModel->where('template_name','forex')->first();
|
||||
$data = $this->mailTemplateModel->where('template_name', 'forex')->first();
|
||||
|
||||
if (!$data || empty($data['image_location'])) {
|
||||
return $this->respond([
|
||||
'status' => 404,
|
||||
'message' => 'Image not found',
|
||||
'url' => null
|
||||
]);
|
||||
}
|
||||
|
||||
// If the DB stores only the filename, adjust accordingly
|
||||
$fileName = basename($data['image_location']);
|
||||
|
||||
|
||||
$imageUrl = base_url('public/assets/images/signature/' . $fileName);
|
||||
|
||||
// Add both the URL and ready-made HTML tag
|
||||
$data['image_url'] = $imageUrl;
|
||||
$data['image_tag'] = '<img src="' . $imageUrl . '" alt="Signature" style="max-width:200px;">';
|
||||
|
||||
return $this->respond([
|
||||
'status' => 200,
|
||||
'message' => 'success',
|
||||
'data' => $data
|
||||
|
||||
'url' => $$imageUrl
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
Loading…
Reference in New Issue
Block a user