0

サーバーから MIDI ファイルをダウンロードするために PHP スクリプトを使用しています。ダウンロードは成功しましたが、ダウンロード ファイルを開くことができません (エラーが発生しました: ファイルの形式が正しくありません)。これは私のコードです:

<?php
$id = $_GET["id"];
if($id == "")
{
print("Invalid download code!");
}
else
{

include_once("libs/htdu_core.php");
$exec_mysql = new execute_mysql_query();
$escape_array = $exec_mysql->escape_string(array($id));
$query = sprintf("select songpath from songs, downloads where downloadcode = '%s' and  songs.songnum = downloads.songnum",$escape_array[0]);
$path = $exec_mysql->execute($query, 1);
if($path == "")
{
print("Invalid download code!");
}
else
{
$fname = substr($path, strpos($path, '/')+1);
//$query = sprintf("update downloads set isdownload = 1 where downloadcode = '%s'",$escape_array[0]);
//$exec_mysql->execute($query, 0);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: audio/midi");
header("Content-Disposition: attachment; filename='".$fname."'");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($path));
set_time_limit(0);
readfile($path);
exit;
}
}
?>

手伝ってくれてありがとう!

4

0 に答える 0