Shoutbox

How do you make a php file a download? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: How do you make a php file a download? (/showthread.php?tid=40676)

How do you make a php file a download? by .Roy on 03-20-2005 at 10:34 AM

Ok i have a site and i want people to download a php script. But if i link to it the people get bunch of gibberish. how do i get  them to download the script?


RE: How do you make a php file a download? by Ahmad on 03-20-2005 at 10:38 AM

One option is to put it in a zip file.


RE: How do you make a php file a download? by .Roy on 03-20-2005 at 10:42 AM

hmm i dont want to go through that trouble. Its annoying to put a 1 kb zip. whats the other options?


RE: How do you make a php file a download? by Millenium_edition on 03-20-2005 at 10:45 AM

quote:
Originally posted by Hobbes
hmm i dont want to go through that trouble. Its annoying to put a 1 kb zip. whats the other options?
if that's trouble, then you shouldn't have a webspace on your hands ¬¬
RE: How do you make a php file a download? by John Anderton on 03-20-2005 at 11:22 AM

quote:
Originally posted by Hobbes
But if i link to it the people get bunch of gibberish

Is your host a php supporting one ^o)

quote:
Originally posted by Hobbes
hmm i dont want to go through that trouble. Its annoying to put a 1 kb zip. whats the other options?
Its just a zip :undecided:
Rar it :dodgy: :P
U could make it a txt and when ppl open it, tell em to copy the text completely, open notepad, paste it and then save it as .php
(In the save as box, unselect the text file option and keep it on all files then type the extension yourself)
RE: How do you make a php file a download? by segosa on 03-20-2005 at 11:39 AM

You can save it as .phps (s = source) which shows them syntax-highlighted source code and the script isn't parsed..


RE: How do you make a php file a download? by -dt- on 03-20-2005 at 11:46 AM

quote:
Originally posted by Segosa
You can save it as .phps (s = source) which shows them syntax-highlighted source code and the script isn't parsed..
and if your server dosnt support that use a script like this

code:
<?

$file = $_GET['file'];
if(isset($file)){
$file = "./$file";
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=$file");

$pic = fopen($file,'r');
$php = fread($pic,filesize($file));
fclose($pic);
echo $php;

}else{
echo "blah";
}

?>


which will take ?file=filename  on the url then ask the user if they wish to download the file , this will only download files from the same directory the script is in.
RE: How do you make a php file a download? by .Roy on 03-20-2005 at 01:10 PM

-dt- i dont really understand what you are saying

can u put it in step to step instructions
Thanks


RE: How do you make a php file a download? by -dt- on 03-20-2005 at 01:14 PM

step1: copy and paste my code into notepad and save it as "phpdl.php"

step2: upload it to a directory on your server

step3: move the files you want to show the source of into that folder

step4: to download that script use http://yoururl/phpdl.php?file=scriptfilename

that should work :P


RE: How do you make a php file a download? by .Roy on 03-20-2005 at 01:29 PM

well -dt- THANKS A BUNCH!!!

Lee helped me work out the technical problems! But thanks for the script :P