How to set URL direct donwloadable



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-2















I have a short video sharing website. The user can download video from there. I'm facing some problem now. I want the user to download the video directly but when users visit my link browser auto-playing the video.



I only want when user click on link Video download will start auto.



Now I'm sharing video link like this
Example: www.example.com/examle.mp4



Please give me suggestion










share|improve this question



















  • 1





    If you are using bootstrap. there is a tag with download to direct download. eg: <a href="YOUR_URL" download >Download</a>

    – Gulshan
    Nov 15 '18 at 10:11











  • Its not only about bootstarp. I want my link direct downloadable. I can share my URL anywhere, when visitor click on my URL, then browser will start downloading the video. I dont want it to play online.

    – Tanjil Islam
    Nov 15 '18 at 10:15











  • Not sure this needs any PHP involvement, as suggested in the two currently existing answers. Setting the Content-Type header should be enough for force a download, and that can be done in a RewriteRule directly, using the T flag

    – misorude
    Nov 15 '18 at 10:40

















-2















I have a short video sharing website. The user can download video from there. I'm facing some problem now. I want the user to download the video directly but when users visit my link browser auto-playing the video.



I only want when user click on link Video download will start auto.



Now I'm sharing video link like this
Example: www.example.com/examle.mp4



Please give me suggestion










share|improve this question



















  • 1





    If you are using bootstrap. there is a tag with download to direct download. eg: <a href="YOUR_URL" download >Download</a>

    – Gulshan
    Nov 15 '18 at 10:11











  • Its not only about bootstarp. I want my link direct downloadable. I can share my URL anywhere, when visitor click on my URL, then browser will start downloading the video. I dont want it to play online.

    – Tanjil Islam
    Nov 15 '18 at 10:15











  • Not sure this needs any PHP involvement, as suggested in the two currently existing answers. Setting the Content-Type header should be enough for force a download, and that can be done in a RewriteRule directly, using the T flag

    – misorude
    Nov 15 '18 at 10:40













-2












-2








-2








I have a short video sharing website. The user can download video from there. I'm facing some problem now. I want the user to download the video directly but when users visit my link browser auto-playing the video.



I only want when user click on link Video download will start auto.



Now I'm sharing video link like this
Example: www.example.com/examle.mp4



Please give me suggestion










share|improve this question
















I have a short video sharing website. The user can download video from there. I'm facing some problem now. I want the user to download the video directly but when users visit my link browser auto-playing the video.



I only want when user click on link Video download will start auto.



Now I'm sharing video link like this
Example: www.example.com/examle.mp4



Please give me suggestion







php html web hosting cpanel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 10:11









D.Mendes

11810




11810










asked Nov 15 '18 at 10:09









Tanjil IslamTanjil Islam

113




113







  • 1





    If you are using bootstrap. there is a tag with download to direct download. eg: <a href="YOUR_URL" download >Download</a>

    – Gulshan
    Nov 15 '18 at 10:11











  • Its not only about bootstarp. I want my link direct downloadable. I can share my URL anywhere, when visitor click on my URL, then browser will start downloading the video. I dont want it to play online.

    – Tanjil Islam
    Nov 15 '18 at 10:15











  • Not sure this needs any PHP involvement, as suggested in the two currently existing answers. Setting the Content-Type header should be enough for force a download, and that can be done in a RewriteRule directly, using the T flag

    – misorude
    Nov 15 '18 at 10:40












  • 1





    If you are using bootstrap. there is a tag with download to direct download. eg: <a href="YOUR_URL" download >Download</a>

    – Gulshan
    Nov 15 '18 at 10:11











  • Its not only about bootstarp. I want my link direct downloadable. I can share my URL anywhere, when visitor click on my URL, then browser will start downloading the video. I dont want it to play online.

    – Tanjil Islam
    Nov 15 '18 at 10:15











  • Not sure this needs any PHP involvement, as suggested in the two currently existing answers. Setting the Content-Type header should be enough for force a download, and that can be done in a RewriteRule directly, using the T flag

    – misorude
    Nov 15 '18 at 10:40







1




1





If you are using bootstrap. there is a tag with download to direct download. eg: <a href="YOUR_URL" download >Download</a>

– Gulshan
Nov 15 '18 at 10:11





If you are using bootstrap. there is a tag with download to direct download. eg: <a href="YOUR_URL" download >Download</a>

– Gulshan
Nov 15 '18 at 10:11













Its not only about bootstarp. I want my link direct downloadable. I can share my URL anywhere, when visitor click on my URL, then browser will start downloading the video. I dont want it to play online.

– Tanjil Islam
Nov 15 '18 at 10:15





Its not only about bootstarp. I want my link direct downloadable. I can share my URL anywhere, when visitor click on my URL, then browser will start downloading the video. I dont want it to play online.

– Tanjil Islam
Nov 15 '18 at 10:15













Not sure this needs any PHP involvement, as suggested in the two currently existing answers. Setting the Content-Type header should be enough for force a download, and that can be done in a RewriteRule directly, using the T flag

– misorude
Nov 15 '18 at 10:40





Not sure this needs any PHP involvement, as suggested in the two currently existing answers. Setting the Content-Type header should be enough for force a download, and that can be done in a RewriteRule directly, using the T flag

– misorude
Nov 15 '18 at 10:40












3 Answers
3






active

oldest

votes


















1














Thank you guys for answering. I want my URL to make direct downloadable. You guys are suggesting me for php file but i found a solution online. This work.



I just need to put this code on .htaccess






<FilesMatch ".(mp4|MP4)">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>





This works perfectly.



Thank you Guys






share|improve this answer






























    0














    <?php
    $file = "www.example.com/examle.mp4";

    header("Content-Description: File Transfer");
    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename='" . basename($file) . "'");

    readfile ($file);
    exit();
    ?>





    share|improve this answer


















    • 1





      Your answer need more explanation about how the code works to be a good answer.

      – Foo
      Nov 15 '18 at 14:48


















    0














    instead of linking to the video file directly you could link to a php file which does trigger the download for you.



    <?php
    header('Content-disposition: attachment; filename=movie.mp4;');
    header('Content-Length: '. filesize('movie.mp4'));
    readfile('movie.mp4');
    exit;


    With .htaccess you could redirect the mp4 link to your php file.



    RewriteEngine on
    RewriteRule ^movie.mp4$ ./movie.php





    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53316986%2fhow-to-set-url-direct-donwloadable%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      Thank you guys for answering. I want my URL to make direct downloadable. You guys are suggesting me for php file but i found a solution online. This work.



      I just need to put this code on .htaccess






      <FilesMatch ".(mp4|MP4)">
      ForceType application/octet-stream
      Header set Content-Disposition attachment
      </FilesMatch>





      This works perfectly.



      Thank you Guys






      share|improve this answer



























        1














        Thank you guys for answering. I want my URL to make direct downloadable. You guys are suggesting me for php file but i found a solution online. This work.



        I just need to put this code on .htaccess






        <FilesMatch ".(mp4|MP4)">
        ForceType application/octet-stream
        Header set Content-Disposition attachment
        </FilesMatch>





        This works perfectly.



        Thank you Guys






        share|improve this answer

























          1












          1








          1







          Thank you guys for answering. I want my URL to make direct downloadable. You guys are suggesting me for php file but i found a solution online. This work.



          I just need to put this code on .htaccess






          <FilesMatch ".(mp4|MP4)">
          ForceType application/octet-stream
          Header set Content-Disposition attachment
          </FilesMatch>





          This works perfectly.



          Thank you Guys






          share|improve this answer













          Thank you guys for answering. I want my URL to make direct downloadable. You guys are suggesting me for php file but i found a solution online. This work.



          I just need to put this code on .htaccess






          <FilesMatch ".(mp4|MP4)">
          ForceType application/octet-stream
          Header set Content-Disposition attachment
          </FilesMatch>





          This works perfectly.



          Thank you Guys






          <FilesMatch ".(mp4|MP4)">
          ForceType application/octet-stream
          Header set Content-Disposition attachment
          </FilesMatch>





          <FilesMatch ".(mp4|MP4)">
          ForceType application/octet-stream
          Header set Content-Disposition attachment
          </FilesMatch>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 10:45









          Tanjil IslamTanjil Islam

          113




          113























              0














              <?php
              $file = "www.example.com/examle.mp4";

              header("Content-Description: File Transfer");
              header("Content-Type: application/octet-stream");
              header("Content-Disposition: attachment; filename='" . basename($file) . "'");

              readfile ($file);
              exit();
              ?>





              share|improve this answer


















              • 1





                Your answer need more explanation about how the code works to be a good answer.

                – Foo
                Nov 15 '18 at 14:48















              0














              <?php
              $file = "www.example.com/examle.mp4";

              header("Content-Description: File Transfer");
              header("Content-Type: application/octet-stream");
              header("Content-Disposition: attachment; filename='" . basename($file) . "'");

              readfile ($file);
              exit();
              ?>





              share|improve this answer


















              • 1





                Your answer need more explanation about how the code works to be a good answer.

                – Foo
                Nov 15 '18 at 14:48













              0












              0








              0







              <?php
              $file = "www.example.com/examle.mp4";

              header("Content-Description: File Transfer");
              header("Content-Type: application/octet-stream");
              header("Content-Disposition: attachment; filename='" . basename($file) . "'");

              readfile ($file);
              exit();
              ?>





              share|improve this answer













              <?php
              $file = "www.example.com/examle.mp4";

              header("Content-Description: File Transfer");
              header("Content-Type: application/octet-stream");
              header("Content-Disposition: attachment; filename='" . basename($file) . "'");

              readfile ($file);
              exit();
              ?>






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Nov 15 '18 at 10:17









              Banujan BalendrakumarBanujan Balendrakumar

              9921213




              9921213







              • 1





                Your answer need more explanation about how the code works to be a good answer.

                – Foo
                Nov 15 '18 at 14:48












              • 1





                Your answer need more explanation about how the code works to be a good answer.

                – Foo
                Nov 15 '18 at 14:48







              1




              1





              Your answer need more explanation about how the code works to be a good answer.

              – Foo
              Nov 15 '18 at 14:48





              Your answer need more explanation about how the code works to be a good answer.

              – Foo
              Nov 15 '18 at 14:48











              0














              instead of linking to the video file directly you could link to a php file which does trigger the download for you.



              <?php
              header('Content-disposition: attachment; filename=movie.mp4;');
              header('Content-Length: '. filesize('movie.mp4'));
              readfile('movie.mp4');
              exit;


              With .htaccess you could redirect the mp4 link to your php file.



              RewriteEngine on
              RewriteRule ^movie.mp4$ ./movie.php





              share|improve this answer



























                0














                instead of linking to the video file directly you could link to a php file which does trigger the download for you.



                <?php
                header('Content-disposition: attachment; filename=movie.mp4;');
                header('Content-Length: '. filesize('movie.mp4'));
                readfile('movie.mp4');
                exit;


                With .htaccess you could redirect the mp4 link to your php file.



                RewriteEngine on
                RewriteRule ^movie.mp4$ ./movie.php





                share|improve this answer

























                  0












                  0








                  0







                  instead of linking to the video file directly you could link to a php file which does trigger the download for you.



                  <?php
                  header('Content-disposition: attachment; filename=movie.mp4;');
                  header('Content-Length: '. filesize('movie.mp4'));
                  readfile('movie.mp4');
                  exit;


                  With .htaccess you could redirect the mp4 link to your php file.



                  RewriteEngine on
                  RewriteRule ^movie.mp4$ ./movie.php





                  share|improve this answer













                  instead of linking to the video file directly you could link to a php file which does trigger the download for you.



                  <?php
                  header('Content-disposition: attachment; filename=movie.mp4;');
                  header('Content-Length: '. filesize('movie.mp4'));
                  readfile('movie.mp4');
                  exit;


                  With .htaccess you could redirect the mp4 link to your php file.



                  RewriteEngine on
                  RewriteRule ^movie.mp4$ ./movie.php






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 15 '18 at 10:25









                  AndreasAndreas

                  443




                  443



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53316986%2fhow-to-set-url-direct-donwloadable%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Use pre created SQLite database for Android project in kotlin

                      Darth Vader #20

                      Ondo