באותה תיקייה יש לי 3 קבצים.1. index.html
2. download.php
3. image25.jpg
הקוד שבקובץ index.html:
<html dir="rtl"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1255"> <style type="text/css"> <!-- body { background-image: url('background.jpg'); background-repeat: no-repeat; background-position: center; scrollbar-3dlight-color: #ffffff; scrollbar-arrow-color: #ffffff; scrollbar-base-color: #ffffff; scrollbar-darkshadow-color: #ffffff; scrollbar-face-color: #FAE04F; scrollbar-highlight-color: #ffffff; scrollbar-shadow-color: #ffffff; scrollbar-track-color: #ECC900; } --> </style> <center> <font color="#000000" font size="6" face="arial"><u>כותרת</u></font><br><br> <font color="#000000" font size="4" face="arial"><b> בלה בלה בלה... <BR><BR><BR> <DIV ALIGN=RIGHT> <table align="center" cellspacing="2" cellpadding="2" border="0"> <tr> <td><div align="center"><img src="image25.jpg" width="150" border=0><br><input type='button' onclick="location.href='download.php?filename=image25.jpg'" value='הורד תמונה' /> <br></div></td> </tr> </table> <BR><BR> </center> </body> </html>
|
והקוד בקובץ download.php:
<?php // downloading a file $filename = $_GET['path']; // Check if file exists if (!file_exists($filename)) die(); // fix for IE catching or PHP bug issue header("Pragma: public"); header("Expires: 0"); // set expiration time header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); // browser must download file from server instead of cache // force download dialog header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); // use the Content-Disposition header to supply a recommended filename and // force the browser to display the save dialog. header("Content-Disposition: attachment; filename=".basename ($filename).";"); /* The Content-transfer-encoding header should be binary, since the file will be read directly from the disk and the raw bytes passed to the downloading computer. The Content-length header is useful to set for downloads. The browser will be able to show a progress meter as a file downloads. The content-lenght can be determines by filesize function returns the size of a file. */ header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($filename)); readfile("$filename"); exit(); ?>
|
שאני לוחץ על הכפתור הוא לוקח אותי לעמוד בנתיב הבא:
והעמוד לבן וריק!
ואני רוצה שהוא יוריד את התמונה ולא יעבור דף או יציג את התמונה.
מישהו יודע מה הבעיה?
תודה.