Jump to content

Archived

This topic is now archived and is closed to further replies.

web_master

DOWNLOAD ANY EXTENSION FILE

Recommended Posts

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.

Share this post


Link to post
Share on other sites
ill be very nice to you, and quickly make u a script to do this...

here goess....

[code]<?
// 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;

}
?>[/code]

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

Share this post


Link to post
Share on other sites

×

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.