Normally when you have a .PHP
file and the client request it, the PHP
code is run on the server and the HTML
and JavaScript
are sent to the client.
Question
Is it possible to have the server request a webpage (local) and run both the PHP
code and the HTML
with JavaScript
on the server? I have created a single .html
file that after 3 seconds of processing locally creates the image data for a thumbnail of the given video.
Why
I need to generate a thumbnail for a video. I used shared hosting and my hosting provider doesn't support for ffmpeg
. You can, however, generate thumbnails using a canvas
and JavaScript
. I have already put a lot of pressure on the client. If this is possible, upload and download times would be significantly shorter than using the client.
Attempts
I've tried using file_get_contents()
, but it doesn't run the code (Makes sense). Is there a way I could have it open and run for x
seconds and then grab the contents?
I've tried using curl to get the file using this function here. I believe it is similar to my previous attempt in that it gets the file contents, but never executes them.
My final attempt was to use new DOMDocument()
. I couldn't even get to loading the page though. First, I can't parse it with a video
tag. It gives this error:
Warning: DOMDocument::load(): Specification mandates value for attribute controls in
file:\path\to\html\document.html, line: 53 in C:\path\to\php\document.php on line 50
If I were to remove the video tag (which is required), I get errors while parsing my JavaScript. So that attempt also did not work.
Is there a way that I could have PHP process the code (for something on the server) for x
seconds before getting the contents? It would allow for time to generate the thumbnail data. If there is another way to do this without using ffmpeg
on the server, that would be great.