How can u download a php file?!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Black Majin
Forum Newbie
Posts: 22
Joined: Wed Jul 16, 2003 12:51 pm
Location: Garland, Texas

How can u download a php file?!

Post by Black Majin »

Is there any way at all that u can download a php file without it executing?
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

Post by Heavy »

Its in the manual header()
If you want the user to be prompted to save the data you are sending, such as a generated PDF file, you can use the Content-Disposition header to supply a recommended filename and force the browser to display the save dialog.

Code: Select all

<?php
// We'll be outputting a PDF
header("Content-type: application/pdf");

// It will be called downloaded.pdf
header("Content-Disposition: attachment; filename=downloaded.pdf");

// The PDF source is in original.pdf
readfile('original.pdf');
?>
Note: There is a bug in Microsoft Internet Explorer 4.01 that prevents this from working. There is no workaround. There is also a bug in Microsoft Internet Explorer 5.5 that interferes with this, which can be resolved by upgrading to Service Pack 2 or later.

Note: If safe mode is enabled the uid of the script is added to the realm part of the WWW-Authenticate header if you set this header (used for HTTP Authentication).
Black Majin
Forum Newbie
Posts: 22
Joined: Wed Jul 16, 2003 12:51 pm
Location: Garland, Texas

Post by Black Majin »

Noooooo, I ment if u just go to any site, can u download a php file?! I guess its not possible huh?
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

Post by Heavy »

That's like hacking a site. If you want to know, because you want to protect yourself, then it is OK. There are books on the subject.

EDIT: I mean cracking not hacking... We use the hacking word for that in Sweden.

Generally it is not possible to do what you want, since site admins and programmers generally do all they can to prevent what you want to do from happening.
Black Majin
Forum Newbie
Posts: 22
Joined: Wed Jul 16, 2003 12:51 pm
Location: Garland, Texas

Post by Black Majin »

LMAO ok...
Post Reply