Help with simple web routine

Joined
Aug 19, 2018
Messages
36
I am not a programmer, but need help with a website routine. I have a server that will have a video file (MP4) that has a link on the website. When a user clicks the link, the video plays. If the video is missing, the link will show a JPG file instead. That is, the server will have 2 files, a JPG and an MP4. The user clicks on the link which goes to the MP4 on the server. If the MP4 is deleted, the user sees the JPG.
Any help would be appreciated.
 

modi123

[H]ardness Supreme
Joined
Sep 6, 2006
Messages
5,640
What have you tried or looked into?

I would imagine you could create some javascript to check for the file.. there then do what ever.. if not swap out the control with a link to the image.
 
Joined
Aug 19, 2018
Messages
36
What have you tried or looked into?
I would imagine you could create some javascript to check for the file.. there then do what ever.. if not swap out the control with a link to the image.
Since I am not a programmer and don't know javascript, I was hoping to get something a bit more specific. I have taken HTML code before and made it work, but didn't know where to start.
 

Brian_B

2[H]4U
Joined
Mar 23, 2012
Messages
3,356
My first question would be - if your running the server why would the MP4 get mysteriously deleted?

If you delete the file, not being program saavy could you also just swap/edit the html file over to point to the jpg by hand?
 

rhansen5_99

2[H]4U
Joined
Nov 12, 2001
Messages
2,057
Depending on your webserver you could just have some 404 logic if i file is not found to then display your page with a picture on it. If you are using apache you could do somehting in the htaccess file like: https://stackoverflow.com/questions/4017470/replace-invalid-image-url-with-404-image

.htaccess
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule \.(gif|jpe?g|png|bmp) /upload/image404.php [NC,L]


image404.php

<?php
$file = 'image404.jpg';
$type = 'image/jpeg';
header("HTTP/1.0 404 Not Found");
header('Content-Type:'.$type);
header('Content-Length: ' . filesize($file));
readfile($file);
?>

So basically if not found it renders image 404.php which loads the image
 
Top