Monday, February 18, 2013

Viewing a PDF file in Cakephp

Hi Bakers

I am trying to view a PDF file within the body of my cakephp application after uploading it, more like an iframe. The upload works fine but the challenge that i have now is opening the pdf file.

Here is my upload function in my controller which is working fine

function uploadFile() {
$file = $this->data['QmsProcedureKnowledgeManagement']['file'];
if ($file['error'] === UPLOAD_ERR_OK) {
$id = String::uuid();
if (move_uploaded_file($file['tmp_name'], APP . 'qms_procedure_km/' . $file['name'])) {
$this->request->data['QmsProcedureKnowledgeManagement']['filename'] = $file['name'];
$this->request->data['QmsProcedureKnowledgeManagement']['filesize'] = $file['size'];
$this->request->data['QmsProcedureKnowledgeManagement']['filemime'] = $file['type'];
return true;
}
}
return false;
}

and here is how i am trying to view the pdf    in view.ctp   

<?php echo $this->Html->link(APP.'qms_procedure_km/'. $qmsProcedureKnowledgeManagement['QmsProcedureKnowledgeManagement']['filename']); ?>

Thank you in advance.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: