0

I want to read .docx files from URL in PHP, Url has no file extension.

URL Like: http://localhost/demoSite/index.php?entryPoint=download&id=cb77e8d2-c578-4ea1-85de-599a901871d0&type=Documents

This URL gives me a file Doc1.docx file so I want to read that file (Doc1.docx) without download.

Manish Tiwari
  • 1,806
  • 10
  • 42
  • 65
  • file_get_contents ? – Frankich Aug 22 '17 at 12:11
  • When you read the file, you are already downloading it. There is no way to view anything online without downloading a stream of bytes. – Jerodev Aug 22 '17 at 12:14
  • Hello @Jerodev, I agreed. the file is in the upload folder and file name is **4a0e15aa-e827-a1dc-f484-599bfc831657** but it has no extension but i know it's docx. So how can i read it. – Manish Tiwari Aug 22 '17 at 12:20
  • Well, a `docx` file is technically a zip file with a bunch of metadata and document files and folders mixed in. In order to be able to *read* the file, as in read it as if you were to open it using Microsoft Word, you need to convert it to text first. This answer might be helpful: https://stackoverflow.com/questions/19503653/how-to-extract-text-from-word-file-doc-docx-xlsx-pptx-php . It looks like you will have to download the file first before reading it to use `$docObj = new DocxConversion("test.doc");` though. To read the file, run `echo $docText= $docObj->convertToText();` – alexyorke Aug 22 '17 at 17:20

0 Answers0