我正在尝试从上传的 Word 文档 (.doc, .docx, .rtf)
中获取字数统计,但它总是会出现烦人的 Word 格式。
有人解决过这个问题并且知道如何解决吗? 谢谢:)
最佳答案
你需要:
区分文件类型
$file_name = $_FILES['image']['name']; $file_extn = end(explode(".", strtolower($_FILES['image']['name']))); if($file_extn == "doc" || $file_extn == "docx"){ docx2text(); }elseif($file_extn == "rtf"){ rtf2text(); }
将文档转换为文本
https://stackoverflow.com/a/7371315/2512934对于 doc 或 docx http://webcheatsheet.com/php/reading_the_clean_text_from_rtf.php对于 rtf
关于PHP - 从上传的 Microsoft Word 文档中获取字数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17967828/