>/
任意のアイデア:私は特定のフォルダにまたは私のドライブCに転送する必要がありますしかし、/path/to/directory/
に正しい権利を持っています。
あなたのコメントで尋ねられたように。ファイルをダウンロードするコード。
$data = "/path/to/directory/color.json";
header("Content-Type: application/json");
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Disposition: attachment; filename="color.json"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($data));
readfile($data);
exit;
よく知られているポップアップが表示されます。そうでない場合は、file_get_contents("/path/to/directory/color.json")
や関数などへの最初のデータ変数を変更しよう:
/**
* This method sets generates the headers for a file download and sends the file. PHP is exited after this function
*
* @param string $fileName The name of the file, as displayed in the download popup
* @param string $data The path to the file, or the contents of the file
* @param string $contentType The content type of the file
* @param bool $file Whether or not $data is a the path to a file, or the file data.<br />
* True means $data contains the path to the file<br />
* False when $data is a the data as a string
*
* @return void Exits PHP
*/
function outputForDownload($fileName, $data, $contentType, $file = true)
{
header("Content-Type: {$contentType}");
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Disposition: attachment; filename="' . $fileName . '"');
header('Content-Transfer-Encoding: binary');
if ($file === true) {
header('Content-Length: ' . filesize($data));
readfile($data);
} else {
header('Content-Length: ' . mb_strlen($data));
echo $data;
}
exit;
}
おかげでその作業。 保存後に前記ファイルをダウンロードする方法も知っていますか?ファイルがサーバーから救われたと仮定すると、私は私の編集を参照してください私の地元 –
にダウンロードしますが、私はまた、私はそれに使用する機能が含まれて – Jelmergu