Page 1 of 1

Download a MIDI-file to a mobile phone

Posted: Tue Jun 28, 2005 1:25 pm
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?

Posted: Tue Jun 28, 2005 1:31 pm
by Burrito

Code: Select all

header("Content-Disposition: attachment; filename=".$yourfilename);

Posted: Tue Jun 28, 2005 1:48 pm
by ronlar
I have tried that header, but it does not solve the problem.

Posted: Wed Jun 29, 2005 2:35 pm
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().