File Force PHP script

SPONSORED LINKS

    Specification

  • Version:
  • File size: 0 KB
  • File name: file_force-6.x-1.1-beta1.tar.gz
  • Last update:
  • Platform: Windows / Linux / Mac OS / BSD / Solaris
  • Language: PHP
  • Price:GPL
  • Company: Garrett Albright (View more)

File Force script description:




Publisher review:
When a site visitor requests a file, File Force can force the user's web browser to download the file to disk instead of displaying it in the browser window. Web browsers today are pre-configured to display various types of media when accessed directly, such as text files, media (image, video and audio) files, PDF documents, and Flash movies. After this happens, it's typically possible for a visitor to save the file to their hard drive using their browser's File menu and/or the item's contextual menu ("right-clicking"); however, novice computer users may not be aware of this, or perhaps you would prefer that visitors view the media in a non-browser application -- or maybe you just want to make sure that visitors will attain a copy of the file for themselves so they don't have to re-visit your site to access it again. File Force solves this problem by offering files with certain HTTP headers which cause the web browser to download the file to the user's disk instead of displaying it in a browser window.

Please note that File Force offers an easy solution to this problem, but it (along with any other solution which requires a scripting language) is not recommended for high-traffic sites and/or sites that need to offer rather large files. Solutions which rely solely on the configuration of the web server should be implemented instead.

Installation and configuration

Install File Force as you would any other module.

Now, let's get hypothetical. Let's say you have your band's latest, greatest song in the file song.mp3 and you want to share it with the world, but you want people to download it instead of just playing it in their browser — and that's why you've installed File Force.

The first rule of File Force is that it only works on files which are in your "File system path." You can view and change this setting by clicking the "File system" link in the "Site configuration" section of the Administer menu. By default, it is "files" for Drupal 5 and "sites/default/files" for Drupal 6. So either put the file there manually, or, if you're using Drupal's optional Upload module, attach the file to a node somewhere and it will be put there. (Note that File Force will still work if you've changed the file system path from the defaults mentioned above.)

At this point, people can now download the file by going to http://example.com/files/song.mp3 in Drupal 5, or http://example.com/sites/default/files/song.mp3 in Drupal 6. However, File Force will not operate when someone tries to access song.mp3 like that — the file will open in the visitor's browser.

Which brings us to the second rule of File Force… In order for it to work on song.mp3, you must link visitors to the path "files/download/song.mp3". Paths that start with "files/download" kick File Force into action. What it does is strip off the "files/download/" part of the path, and look for the rest of it — in this case, "song.mp3" in whatever your file system path is. Note that this works with subdirectories; so, for example, if you put song.mp3 inside a subdirectory called music, you'd want to link to the path "files/download/music/song.mp3".

There's a teensy problem that goes along with this, though; in your links to files, you need to account for whether your site has Clean URLs enabled. If not, you need to account for that when you create links to your files, and add a ?q= particle to the beginning of the path. So, to link to "song.mp3":

Note

Note that installing File Force does not mean that visitors will no longer be able to view files in their browser window at all. The files will still be accessible at their initial paths as mentioned in the example above. Only when you use the "files/download/" prefix does File Force kick into action. This also means that the default file listings created by the Upload module will not provide links to the File Force path, instead linking directly to the file (which will be opened in a browser window). Future versions of File Force may address this, but for now, you should either upload your files to the files directory directly, bypassing the Upload module, or configure the Upload module to not show listings of attached files when nodes are viewed. Then link to the file using the File Force path in the node's content. Requirements: ยท Drupal 5.x or higher.
File Force is a PHP script for Drupal Modules scripts design by Garrett Albright. It runs on following operating system: Windows / Linux / Mac OS / BSD / Solaris.

Operating system:
Windows / Linux / Mac OS / BSD / Solaris

Latest script and internet news

222

222

22

Posted on: 18 Jul 2023 22:27 by A. Brown

111

111

111

Posted on: 18 Jul 2023 22:24 by A. Brown

The permanently active Push system offered by the new Google Chrome 42

The permanently active Push system offered by the new Google Chrome 42

Hacked By !Sc-sT

Posted on: 17 Mar 2015 07:57 by A. Brown

SPREAD THE WORD

User Rating


Rating: 2.2 out of 5
Based on 13 ratings. 13 user reviews.

  • Currently 2.15 out of 5
  • 1
  • 2
  • 3
  • 4
  • 5