Display .docx (.doc) on Browser without downloading in php

前端 未结 1 1445
温柔的废话
温柔的废话 2021-02-15 22:03

Is there any alternative way of viewing a file(locally/online) in PHP? Since I want to display a .docx (.doc) file in my browser but it keeps on downlo

1条回答
  •  北荒
    北荒 (楼主)
    2021-02-15 22:44

    After a lot research i found a best solution to display almost every type of document in browser using iframe.

    Solution is Google Docs Viewer

    Just use iframe as given below and replace url of document in it.

    
    

    By Replacing sample url for .docx file, above code becomes.

    
    

    By Replacing sample url for .pdf file, above code becomes.

    
    

    Note: Document that you need to display in browser must have correct url and must be publicly available, because Google needs to fetch and display document, process fails if document is private and you will see iframe with NO PREVIEW AVAILABLE

    0 讨论(0)
提交回复
热议问题