Jump to content


Photo

DOWNLOAD ANY EXTENSION FILE


  • Please log in to reply
1 reply to this topic

#1 web_master

web_master
  • Members
  • PipPipPip
  • Advanced Member
  • 419 posts
  • LocationSerbia

Posted 05 July 2006 - 08:23 AM

Hello,

I need a simpliest php-script for a download any extensions files from a server. Example: The script generate the csv-file, and I want that the Administrator can download this file, and that he can give a file-name before a downloading. How it can look like? You know - form window for a file name and submit button. Only that.

It can work that I can change the downloadet files extension for a any time I want to download other file somewhere else...

In advanced thanks.

#2 hsncool

hsncool
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 09 July 2006 - 06:18 PM

ill be very nice to you, and quickly make u a script to do this...

here goess....

<?
// EDIT HERE!!!

$file = "HERE"; // change HERE to the file you wish to be downloaded. do not include the csv extension.

//NO NEED TO EDIT BELOW THIS LINE!!!!!

echo('<a href="?">start page</a><br /><br />');
$action=$_GET['download'];
$ext = '.csv';
$filename=$_GET['filename'];


if(!$action == true) {
echo('<form action="?" method="get">
<input name="download" type="hidden" value="true" /><br />
Filename: <input name="filename" type="text" /> - this is the filename you wish the download to have, without the extension<br />
<input name="" type="submit" value="Download!!" />
</form>');

} else {


$download = $file . $ext;
$name = $filename . $ext;


if(file_exists("$download")) {
	header("Content-type: application/force-download");
	header ("Content-Length: ".filesize($download));
	header("Content-Disposition: attachment; filename=$name");
	@readfile("$download");
} else {
echo('no such file');
}
exit;

}
?>

i havnt tested this, if it has any probs, please tell mee, and ill correct em.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users