Content Disposition problem: incorrec... Search Search

Now SMS/MMS Gateway » WAP Technical Discussions (not for product support) » Content Disposition problem: incorrect filename « Previous Next »

Author Message
Graham Macaskill
New member
Username: Grahamm

Post Number: 1
Registered: 05-2007
Posted on Tuesday, May 29, 2007 - 05:28 pm:   

Hi

I have a problem with download filenames. Files downloaded to Samsung mobile phones using php readfile are not named properly on save. The file name ends up as something like sid=adfdggffg (this is a get parameter passed in the url) instead of pic.jpg. Any ideas on why this happens?

Here's the code
if (!$fdl = @fopen ($fileName,'r')){
die ("Cannot Open File!");
} else {
$pathinfo = pathinfo ($fileName);
$extension = $pathinfo['extension'];
switch (trim (strtolower ($extension))) {
case "gif": $contentType = "image/gif"; break;
case "jpg": $contentType = "image/jpeg"; break;
//case "jpg": $contentType = "image/jpg"; break;
case "jpeg": $contentType = "image/jpeg"; break;
case "bmp": $contentType = "image/bmp"; break;
case "wbmp": $contentType = "image/vnd.wap.wbmp"; break;
case "amr": $contentType = "audio/amr"; break;
case "mid": $contentType = "audio/midi"; break;
case "mp3": $contentType = "audio/mpeg3"; break;
case "wav": $contentType = "audio/wav"; break;
case "3gp": $contentType = "video/3gpp"; break;
case "mp4": $contentType = "video/mp4"; break;
case "mpg": $contentType = "video/mpeg"; break;
default: $contentType = "multipart/mixed"; break;
}
header ("Content-type: $contentType");
header ("Content-Disposition: attachment; filename=\"" . basename ($fileName) . "\"");
header ("Content-length:" . (string) (filesize ($fileName)));
sleep (1);
readfile ($fileName);
fclose ($fdl);
Bryce Norwood - NowSMS Support
Board Administrator
Username: Bryce

Post Number: 7279
Registered: 10-2002
Posted on Monday, June 25, 2007 - 08:03 pm:   

Hi,

You could try adding the file name to the "Content-type:" parameter using "name=xxxxx" ... but it sounds like the browser in question just is not very smart.

I'd probably take the easy way out, and when building my GET URLs, I would put the filename in the last paramter ... even though it sounds like you might end up with "parm=" as part of the name. (Maybe using "parm=/filename.ext" would get around that.)

A thought for you anyway ...

-bn

Add Your Message Here
Post:
Bold text Italics Underline Create a hyperlink Insert a clipart image

Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Click here to register with this discussion board.
Password:
Options: Automatically activate URLs in message
Action:

Search Search Tree View Tree View   Home Home
Login Login / Register Topics Topics Search Last 1|3|7 Days   Previous Page Previous Next Next Page

© Copyright 2002-2007 by Now Wireless Limited
Airport House, Purley Way, Croydon, London, CR0 0XZ, UK
UK Tel: +44-20-8286-8080 US Tel: +1.410.833.8711
email : nowsms@now.co.uk