そのため、アップロード/ダウンロード システムを機能させようとしましたが、問題が発生し続けました。具体的には、ダウンロードしたファイル (.xls) が破損しています。
これは私が現在持っているものです:
<form action="{{block type=" core/template" name="my-template"
template="php/download_file.php" }}" method="post">
<label for="date">Date:</label>
<input type="date" name="date" id="date"><br>
<input type="submit" name="submit" value="Download">
</form>
<a href="link/to/file">download file</a>
したがって、これらは両方とも同じファイルにリンクされ、正常にダウンロードされます。ファイルのダウンロード リンクをクリックすると、ファイルが問題なく開きます。フォームのダウンロード ボタンをクリックすると、ダウンロードされますが、開くと警告/エラーが表示されます。
ダウンロードファイル.php:
<?php
if($_POST['submit']) {
$file = 'excel_file.xls';
// Magento file path
$path = Mage::getBaseUrl('media') . 'folder' . DS . $file;
header("Content-Type: application/vnd.ms-excel");
//header("Content-Type: application/octet-stream");
header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename = 'filename'");
echo $path;
exit;
}
?>
何か関係がある場合に備えて、これはすべてMagento Static Blockにあります。どんな助けでも大歓迎です。ありがとう。