Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 21st, 2006, 04:04 AM
Registered User
 
Join Date: Jul 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default content disposition

header('Content-type: image/jpeg');
header('Content-Disposition: attachment; filename="' .$filename. '"');
    header("Content-Length: " . filesize("cache/" .$filename));
    readfile("cache/" . $filename);


Note: the above code is only for jpg images.

The code is working fine in the sense that giving me correct size and file name but when it is saved/downloaded not showing . Says no preview available.

The main idea to write this sort of code is to hide path of the file.


Please help. Thanks in advace.
 
Old May 24th, 2006, 11:49 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Look at the source of the JPEG as it is when downloaded using your script (open the JPEG with notepad, wordpad, TextEdit, or another text editor of your choice). If you don't immeditately see what's wrong, compare the file with the original by opening the orignal in a text editor as well. Sometimes you might have a space character inserted at the front, or maybe you have magic quotes enabled and PHP has inserted slashes into the raw source. stripslashes will correct that in most cases, if disabling magic quotes isn't an option.

HTH!

Regards,
Rich

--
Author,
Beginning CSS: Cascading Style Sheets For Web Design
CSS Instant Results

http://www.catb.org/~esr/faqs/smart-questions.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
Centering content Europom CSS Cascading Style Sheets 2 February 18th, 2008 06:25 AM
Webbrowser content vincentvdm BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 0 January 12th, 2008 10:52 AM
Suppressing content fatex9994 Crystal Reports 0 November 20th, 2006 01:30 PM
Choosing content depending on content of other ele dsekar_nat XSLT 1 February 27th, 2006 05:58 AM
Content management?? haggis82 Dreamweaver (all versions) 1 December 9th, 2004 03:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.