Grow your CSS skills. Land your dream job.

Creating a .m4v Download Link

  • # April 11, 2010 at 11:48 pm

    I’m attempting to create download links on several pages for .m4v video files. One of the pages is here: http://gkeagles.org/drew-austin-qb-2/. The setup is intended to be somewhat similar to the Screencast pages on CSS-Tricks, where visitors can watch online or download.

    The problem I’m having is in creating the download link. My understanding is that I would simply use an <a href> element: <a href="video-url">Click Here</a> to download. When I do so, however, clicking on the link doesn’t initiate a download, it just tries to navigate to the specified url. As a stop-gap in the meantime I’m going to upload a .zip of each video and link to that, which should force a download. Is there a way to force a download when linking to a .m4v file?

    Thanks in advance for any help.

    # April 12, 2010 at 3:56 am

    I’m not completely familiar with this, though I believe it is possible to force the download using a .htaccess file.

    Try this: create a .htaccess file in the server root (or add to it if that file already exists) and add these contents:

    Code:
    AddType application/octet-stream .m4v

    (according to http://www.askapache.com/htaccess/ultim … ample.html — see the "## FORCE FILE TO DOWNLOAD INSTEAD OF APPEAR IN BROWSER ###" section).

    However, do check — adding this line may mean that if you try to play a .m4v video (though a video player, rather than linking it) the file will attempt to download. If that is the case (I’m not sure off the top of my head), using a .zip file may be the best way to go. Perhaps other members will have some additional ideas as well.

    # April 12, 2010 at 10:36 am

    @falkencreative

    Thanks for the info — I had looked at this technique as well but wasn’t sure. Added the line to my .htaccess file, but it didn’t work.

    One important piece of information i forgot to add in my initial request: the site is built in WordPress, so I’m attempting to add the download links in posts. I don’t know if that makes a difference, but thought I should mention it.

    Update 4/13/10: I really, really hope someone out there will take pity on me and offer some help on this one. I suspect it has something to do with the fact that I’m attempting to do this inside a WordPress post: no matter what I do (including one attempt to use php to force a download) clicking on the file link just tries to open a new page. I’m due to hand the project over to the client tomorrow and would really like to have this issue solved before then.

    # January 20, 2013 at 7:52 pm

    Did you ever get an answer for how to write html so that an m4v video link is downloaded instead of played? I too want to do that on my site. Thanks, Wayne

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".