<?php
$filepath = 'target.php';
$filesize = filesize($filepath);
$path_parts = pathinfo($filepath);
$filename = $path_parts['basename'];
$extension = $path_parts['extension'];
header("Pragma: public");
header("Expires: 0");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename='$filename'");
header("Content-Transfer-Encoding: binary");
header("Content-Length: $filesize");
ob_clean();
flush();
readfile($filepath);
The code above makes download a file “target.php” which is in the same directory.
As I check it, “target.php” is downloaded with the name the quote below.
actual downloaded file name
I expected “target.php” is downloaded with the name the quote below.
target download file name
How can I make it downloaded with taking the single quote and double quote off before and after the file name “target.php”?