Hi, I have an HTML5 video tag, I want to give the user a “Download” button where the User can click and download this video. I know that a user can download videos by right-clicking on browsers, but I want this feature to appear on my button.
I use simple code
$('submit').click(function() { window.location.href = 'myvideo.mp4'; });
but it redirects me to a video that does not show the download popup that I want.
thanks
HTML5 download <a> DOM. JavaScript.
download
<a>
: fooobar.com/questions/77175/...
, PHP -
<?php header('Content-type: application/octet-stream'); readfile('myvideo.mp4');
:
$('submit').click(function() { $('<a/>',{ "href":"The/video/src/path", "download":"video.mp4", id:"videoDownloadLink" }).appendTo(document.body); $('#videoDownloadLink').get(0).click().remove(); });
Based on the answer of the Meganians:
header("Content-disposition: attachment; filename=" . basename($filename) .'"'); header('Content-type: application/octet-stream'); readfile($filename);'
Thanks, Megan. I copied and modified your code.
Source: https://habr.com/ru/post/1619154/More articles:MS Sql combined with zero values - sqlhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1619150/can-i-make-realm-results-class-to-use-protocol-as-generics&usg=ALkJrhifPvTbjm8LcKNR7Dao5DKCTjf4KAОшибка запроса соединения Linq - c#Символ не найден: _SSLv2_client_method (LoadError) - rubycontact form 7 wordpress - wordpressзагрузка загрузочного файла с предварительным просмотром изображений - htmlDo getters violate the Law of Demeter? - javatrigger popup or div id on finished document - javascriptdemeter and planetary law - c ++ForEach for a list of a list in Linq - listAll Articles