php - form vs href link corrupt -
so have been trying upload/download system work kept running problems, specifically, downloaded file being corrupt (.xls).
this have currently:
<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>
so, these both link same file , downloads fine. if click on download file link, file opens fine. if go through form download button, it'll download opening gives me warning/error: "the file format , extension of 'file' don't match" , hangs forcing me force close file.
download_file.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; } ?>
this in magento static block, in case has it. appreciated. thanks.
have tried this:
header("content-type: application/vnd.ms-excel; charset=utf-8"); header("content-disposition: attachment; filename=abc.xls"); //file name extension wrong header("expires: 0"); header("cache-control: must-revalidate, post-check=0, pre-check=0"); header("cache-control: private",false);
greetings.
Comments
Post a Comment