Jump to content

DOWNLOAD ANY EXTENSION FILE


web_master

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.
Link to comment
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.
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.