Jump to content

[SOLVED] A script sending a .php file for user?


NikkiLoveGod

Recommended Posts

Hi everyone!

 

Im having a little problem here, I am making a simple script here, that just lists the files in a folder, makes them a link and when the user clicks the link, he SHOULD be getting a download prompt for a .php file, but that is what im having a problem here. Of course it is trying to redirect the browser to a .php file, when it is just a simple <a href="http://xxx.com/xxx/example.php">. Im thinking this has something to do with either server settings, or headers, prolly headers.

 

So any ideas, how can I make it so that when I press the link, it will download the php file, instead of redirecting? Its a little hard subject to try and google it :S

 

Thanks!

-NikkiLoveGod

Link to comment
Share on other sites

EDIT: oops, looks like it kinda fucked up the message, when I tried to put a example code :D ( AND BUMP )

 

Hi everyone!

 

Im having a little problem here, I am making a simple script here, that just lists the files in a folder, makes them a link and when the user clicks the link, he SHOULD be getting a download prompt for a .php file, but that is what im having a problem here. Of course it is trying to redirect the browser to a .php file, when it is just a simple < a href="test.php>. Im thinking this has something to do with headers.

 

So any ideas, how can I make it so that when I press the link, it will download the php file, instead of redirecting? Its a little hard subject to try and google it, since i cant really figure out any keywords :S

 

BTW: as a reference, it is done in phpclasses.org !

 

Thanks!

-NikkiLoveGod

Link to comment
Share on other sites

Yea! Thanks :D I found one my self too! heres the one I found my self which allows for download. I need to put up some code to stop some lamers.

 

<?php
$file = "backup.php";
header('Content-Type: Application/Octet-Stream');
header('Content-Disposition: Attachment; Filename="backup.php"');
readfile("backup.php");
?>

 

btw, it seems that the capitalization of the words are very importat, so that the files arent corrupted!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.