Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从word文件文档中获取所有内容并使用php将其显示在div中?_Php_Codeigniter_File Upload - Fatal编程技术网

如何从word文件文档中获取所有内容并使用php将其显示在div中?

如何从word文件文档中获取所有内容并使用php将其显示在div中?,php,codeigniter,file-upload,Php,Codeigniter,File Upload,上传简历时,我需要预览简历,因为它使用的是PHP CodeiCenter。您可以使用下面的功能 $content = file_get_contents('filepath'); echo $content; 函数读取\u docx(“文件路径”){ $striped_content=''; $content=''; 如果(!$filename | |!file_存在($filename))返回false; $zip=zip\u open($filename); 如果(!$zip |是数值($

上传简历时,我需要预览简历,因为它使用的是PHP CodeiCenter。

您可以使用下面的功能

$content = file_get_contents('filepath');
echo $content;
函数读取\u docx(“文件路径”){
$striped_content='';
$content='';
如果(!$filename | |!file_存在($filename))返回false;
$zip=zip\u open($filename);
如果(!$zip |是数值($zip))返回false;
而($zip\u entry=zip\u read($zip)){
如果(zip_entry_open($zip,$zip_entry)==FALSE)继续;
如果(zip\u entry\u name($zip\u entry)!=“word/document.xml”)继续;
$content.=zip_entry_read($zip_entry,zip_entry_filesize($zip_entry));
zip_entry_close($zip_entry);
}
zip_close($zip);
$content=str_replace(“”,$content);
$content=str_replace(“”,\r\n“,$content);
$striped_content=strip_标签($content);
返回$striped_内容;
}

你实现了相同的功能吗?是的,我实现了相同的功能,但是我用加密的形式获取数据..@萨芬·查科沃:你为什么不使用fopen();
function read_docx("filePath"){

    $striped_content = '';
    $content = '';

    if(!$filename || !file_exists($filename)) return false;

    $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);
    }
    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;
}