WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : How to let a user download a picture by clicking on it instead of needing to right click and Save-As.
Categories : HTTP, PHP, HTML and PHP, Filesystem
Boaz Yahav
Date : Apr 28th 2000
Grade : 3 of 5 (graded 5 times)
Viewed : 9841
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Boaz Yahav
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?
error_reporting(0);
$filename="adi_and_berber.gif";
$path="";
If(!IsSet($command)) $command == 0;
If($command == 0) {
?>
        <HTML>
        <BODY>
        <BR><BR><BR><BR>
        <CENTER>
        <A HREF="PictureDownload.php3?command=1"><IMG SRC="<?echo"$filename";?>" BORDER="0"></A>
        </CENTER>
        </BODY>
        </HTML>
<?
}
If($command == 1) {
        header("Content-Disposition: attachment; filename=$filename");
        header("Content-Type: application/octet-stream");
        header("Content-Length: ".filesize("$path/$filename"));
header("Pragma: no-cache");
header("Expires: 0");
        $fp=fopen("$path/$filename","r");
        print fread($fp, filesize("$path/$filename"));
        fclose($fp);
        exit();

}
?>

View examples here :

http://new.weberdev.com/GeneralDev/examples/1562/DownloadFile.php

http://new.weberdev.com/GeneralDev/examples/1562/PictureDownload.php3



Random Image Display
Categories : PHP, Filesystem, Graphics, HTML and PHP
Simple pipe delimited file export program that downloads to a local machine
Categories : PHP, Filesystem, Databases, MySQL, HTTP
PHP4 HTTP Compression Speeds up the Web
Categories : PHP, Zlib, HTML and PHP, HTTP, Network
Class that allows the PHP developer to create and manage UNIX like password files suitable for use as Apache authentication password files.
Categories : HTTP, PHP, PHP Classes, Filesystem
Remote File Size
Categories : PHP, Filesystem, HTTP, Sockets
Remote File Saving with PHP - Download and serve a remote file. The content of the file will be updated at fixed intervals.
Categories : PHP, Filesystem, Cache, Sockets, HTTP
This script shows you the 7th latest php items from the mailing list archive on zend.com
Categories : HTML, HTML and PHP, HTTP, PHP
Pseudo Non Parsed Header. Output to the the browser as the script runs.
Categories : PHP, HTTP, HTML and PHP
Produces browser-safe strings while preserving HTML tags.
Categories : Strings, HTTP, PHP, HTML and PHP
Easy upload class
Categories : PHP Classes, Filesystem, HTTP, PHP
Browser Detection, Redirection Type, MSIE, MOZILLA, Netscape Navigator, NS, $HTTP_USER_AGENT, HTTP_USER_AGENT
Categories : PHP, HTTP, Browsers, HTML and PHP
Force file download
Categories : PHP, Filesystem, HTTP, Program Execution
Upload Script, Upload File Script, Input Type="File"
Categories : PHP, HTML and PHP, HTTP
upload function using PHP's FTP abilities.
Categories : PHP, Filesystem, HTML and PHP
Opening and formatting text files into HTML on the fly- or HTML from templates.
Categories : PHP, HTML and PHP, Filesystem
 Kelvin Lee wrote :1356
I tried to put the script at bottom in my php script but file could not be ask for download but opened it in the browser.  Why?