web_master Posted July 5, 2006 Share Posted July 5, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/13715-download-any-extension-file/ Share on other sites More sharing options...
hsncool Posted July 9, 2006 Share Posted July 9, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/13715-download-any-extension-file/#findComment-55234 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.