P
P
pavlusha12018-05-10 10:39:38
PHP
pavlusha1, 2018-05-10 10:39:38

How to output doc and xls format files to html or php?

On the server are files, PDF, Doc, Docx, xls, xlsx, jpg. Their names (understandable to the user) and links are stored in the database. The tasks are as follows: 1. when you click on a link with a file name, this file opens
2. there is another link, when you click, all files open.
Problems:
1.PDF and jpg are easy to open, and the rest are just downloaded
2. I can't figure out how to bring everything together...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Siberian_Bear, 2018-05-10
@pavlusha1

Here you need to understand that the formats can be proprietary and others like them. "Opening a doc file in a browser" is like opening psd, ai, cdr, vsd and others. Someone took care of support in browsers - for example pdf. Those. conditionally, adobe called google and said "here is a description for you, make the pdf open in chrome for you." Well, or vice versa, browser developers called adobe and asked. Or, in general, adobe made pdf open (it is necessary to clarify).
This is what I mean: Each format should be considered separately. And connect libraries for correct opening. The browser just doesn't support them. in Chrome, for example, you can install additional applications - and it will intercept the word and open it.
For most popular, not very closed formats such as docx, xlsx, there are a bunch of libraries for different languages. Some are paid, some are not. They are unofficial, so functionality is often limited.
Those. conditional microsoft does not give php-shniks a library to make everything work well. And third-party developers painstakingly study the format and write a program to parse it. Then they sell. For example https://www.phpdocx.com/pricing
Although they seem to have made a library for their language: https://code.msdn.microsoft.com/ASPNET-Document-Vi...
The analogy with the video is the same - by default it is not enough codecs supported. But there are a bunch of player libraries that support a larger number of media formats.
You need to search for, connect and configure the library for each type of file, so that the user would poke at the file, php would parse it and display it as html.
Another example https://github.com/PHPOffice/PHPWord Although generally googling like "php docx"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question