我試圖創建一些代碼,以便用戶可以在opencart下載圖像,而無需右擊並使用Save as...
但我創建此代碼並下載圖像後,嘗試打開圖像說圖像是傷害。圖像下載 - 圖像無法打開
<form action="download.php" method="post" >
<input type="text" name="file" value="<?php echo $image['popup']; ?>" />
<input type="submit" value="download" />
</form>
的download.php
<?php
$file= $_POST["file"];
header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header ("Content-Type: application/octet-stream");
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-type: application/pdf');
header('Content-type: image/jpg');
header('Content-type: image/gif');
header('Content-type: image/png');
readfile('$file');
?>
好吧,當我改變這個ReadFile的($文件)使用;該頁面只是空白..still相同的圖像仍然損壞... :( – ruslyrossi
文件是否存在你試圖打開它的位置? –
是的..但圖像仍然損壞 – ruslyrossi