Download a MIDI-file to a mobile phone

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ronlar
Forum Newbie
Posts: 3
Joined: Tue Jun 28, 2005 1:16 pm

Download a MIDI-file to a mobile phone

Post by ronlar »

I have problem to download a MIDI-file (.mid) to a mobile phone.

I have a page called "download.php":

Code: Select all

<?php 
$filename = $_GET&#1111;'file']; 
$directory = &quote;midi/&quote;; 
$path = &quote;$directory$filename&quote;; 
if (file_exists($path) ) { 
header(&quote;Content-type: audio/midi&quote;); 
readfile(&quote;$path&quote;); 
} 
?>
It works to download the MIDI-file, but the file is saved to the phone as "download.mid", instead of its right name.

On a web browser, the MIDI-file opens and plays with the right name.

Is there any way to solve this?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Code: Select all

header("Content-Disposition: attachment; filename=".$yourfilename);
ronlar
Forum Newbie
Posts: 3
Joined: Tue Jun 28, 2005 1:16 pm

Post by ronlar »

I have tried that header, but it does not solve the problem.
ronlar
Forum Newbie
Posts: 3
Joined: Tue Jun 28, 2005 1:16 pm

Post by ronlar »

If I change "download.php" to have a link instead of the function readfile(), then the MIDI-file is saved to the phone with the right name.

Code: Select all

<?php
$filename = $_GET&#1111;'file']; 
$directory = &quote;midi/&quote;; 
$path = &quote;$directory$filename&quote;;  
if( file_exists($path) ) {
  echo &quote;<a href=$path>Download</a>&quote;;
}
?>
The problem in this case is that the real path to the file is shown. I want it to be hidden, that´s why I have used readfile().
Post Reply