Reputation: 1781
private function read_docx($filename) {
var_dump($filename);
$striped_content = '';
$content = '';
$zip = zip_open($filename);
if (!$zip || is_numeric($zip))
return false;
while ($zip_entry = zip_read($zip)) {
if (zip_entry_open($zip, $zip_entry) == FALSE)
continue;
if (zip_entry_name($zip_entry) != "word/document.xml")
continue;
$content .= zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
zip_entry_close($zip_entry);
}// end while
zip_close($zip);
$content = str_replace('</w:r></w:p></w:tc><w:tc>', " ", $content);
$content = str_replace('</w:r></w:p>', "\r\n", $content);
$striped_content = strip_tags($content);
return $striped_content;
}
I have used the above code for displaying .docx
content in my view
using the below code:
<div style="padding: 10px">
<?php
$fileName = $details->resume_name;
$path = FCPATH . "uploads/document/";
// i have also tried.. $path = base_url() . "uploads/document/"; and $path = FCPATH . "uploads/document/";
$fullPath = $path . $fileName;
echo $CI->docx->read_docx($fullPath);
?>
</div>
But when I run this code it shows me nothing and the result is empty....
Please help me to solve this problem.. or suggest me any similar way to read the content of .docx
file and display it in a simple html page
or in a view
Upvotes: 1
Views: 1050
Reputation: 1781
its working now.. i am answering my own question so that any one else can get help from it...
the problem is with the path here $path = FCPATH . "uploads/document/";
which I have replaced with $path = "./uploads/document/";
Upvotes: 1