×
Namespaces

Variants
Actions

Making image files downloadable for Nokia Asha Web Apps

From Nokia Developer Wiki
Jump to: navigation, search

This article explains how to make image files downloadable for Nokia Asha Web Apps 2.0 Beta

Article Metadata
Tested with
Devices(s): Nokia X3-02
Compatibility
Platform(s): Nokia Series 40 devices
Device(s): All supporting Nokia Browser 2.0
Article
Created: isalento (25 Jun 2012)
Last edited: hamishwillee (09 May 2013)

Overview

Series 40 web apps 2.0 Beta brings support for downloading files. However image files located in remote server do not trigger downloading process unless server is configured to do so. This article describes how image files can be made downloadable in Apache server environment.

Making image files downloadable

The magic word, which enables Nokia Browser to download images, instead of just showing them, is Content-Disposition header (http://www.ietf.org/rfc/rfc2183.txt). Downloading is forced by setting Content-Disposition to attachment and specifying filename. Specified file name is presented to the user in browser’s download dialog. One common way is to use PHP to write content disposition header.

header('Content-type: image/jpeg');
header('Content-Disposition: attachment; filename="image.jpg"');
readfile('image.jpg');

Another way to achieve the same functionality is to use Apache’s mod_headers module. Mod_headers directive provides convenient way to add headers to all of the files with certain extension. Even better, mod_headers directives can be added to .htaccess file. Following code adds Content-Disposition header to all of the *.jpg image files in current directory. Thus now when trying to access any image file in that directory, browser downloads it instead of just showing it.

<FilesMatch "\.(jpg)$">
ForceType image/jpeg
Header set Content-Disposition attachment
</FilesMatch>
This page was last modified on 9 May 2013, at 13:36.
110 page views in the last 30 days.