Page 1 of 1

How can u download a php file?!

Posted: Wed Jul 16, 2003 12:55 pm
by Black Majin
Is there any way at all that u can download a php file without it executing?

Posted: Wed Jul 16, 2003 1:02 pm
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).

Posted: Wed Jul 16, 2003 1:07 pm
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?

Posted: Wed Jul 16, 2003 1:12 pm
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.

Posted: Wed Jul 16, 2003 1:16 pm
by Black Majin
LMAO ok...