0

I created a script that allows you to download a file from the server. My script works, but if the title contains stars and other characters, the file name does not work.

<?php
$path = 'myfile.mp3';
$name = '**filename.mp3';
header('Content-Description: File Transfer');  
header("Content-Type: audio/mp3");  
header("Content-Transfer-Encoding: binary");
header('Content-Disposition: attachment; filename="'.$name.'"'); //return __filename.mp3
readfile($path);
exit(); 
?>

How to repair this script to include other characters. Do you have any idea?

  • `*` is a special character on the OSes in use nowadays. Even if you manage to put it in the file name in the response you send, it cannot be used in file names on Windows. It can be used in file names on Linux and macOS but it produces more harm than good. Try to generate file names that can be used without workarounds and complications on all OSes and file systems. Use only letters, digits, dashes and dots; avoid other characters. – axiac Apr 03 '18 at 15:07
  • Thank you for your answer, now I know why it does not work for me;) – Wojciech Urbaniak Apr 03 '18 at 16:55

0 Answers0