hi guys, just wanna know, how could i download a file using php script? it is possible with visual basic 6 but the problem is how would i do that using php???

To download just the single html file or store it in a variable then the following will do the trick:

//now to save the variable to a html file

Hope that helps.

sir, what if i have several files, i mean i have excel, word, pdf and then different formats, how about that?

the thing is that it's already downloaded, what i want is that the user will have an option either open, save or cancel the download.

how can i do thaT?

Simply link to another page or same page where filesaving fails to pass if statement. Below is an example:

if ($_GET['id']=='save') {
foreach ($links AS $link) {
echo '<a href="index.php?id=save">Save files</a><br>';
if ($_GET['id']=='save') {
    echo '<a href="index.php"><b>Cancel Download</b></a>';

That should do the trick.

where did those files go sir?

Same folder as the script was placed.


if(!$file) return false;
elseif(!$content) return false;
else { header("Content-disposition: attachment; filename=$file");
header('Content-type: $content');
readfile("$file"); }
<a href='./savefile.php?file=filename&content=contenttype'>download filename</a>

keep a folder full of downloads
this script as index.php in that folder lets me dump anything in it and it autoupdates the displayed list
line 20 lets you set the filetypes it will handle

<?php ob_start("ob_gzhandler"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php $p = split('/', $_SERVER['SCRIPT_FILENAME']);
$script_name = $p[count($p)-1];
$path = str_replace($script_name, '', $_SERVER['SCRIPT_FILENAME']);
$dir_handle = @opendir($path) or die("Unable to open $path");
Function get_Extension($m_FileName){
$path_parts = pathinfo($m_FileName);
if ($path_parts["extension"]) { $m_Extension = strtolower($path_parts["extension"]);
return(strtoupper($m_Extension));  		}
else { return "unknown file types"; }
 function check_image($filename){
 if(($temp=="PDF")||($temp=="XLS")||($temp=="DOC")) return (true);
 else return (false);
 Function get_Files($path) {
if ($handle = opendir($path)) {	
while (false !== ($file = readdir($handle))) { 
if(!is_dir($file) && substr($file,O,1) != "."){ $m_Files[]=$file; 	}
 if(sizeof($m_Files)>1) asort($m_Files);
 return $m_Files;
for ($i=0;$i<sizeof($filter_files);$i++){
echo "<div style='margin:4px;'><a href='./savefile.php?file=$filter_files[$i]'>";
echo substr($filter_files[$i], 0, strlen($filter_files[$i])-4);
echo "</a></div>";
closedir($dir_handle); ?>
<?php ob_flush(); ?>

thank you very much sir to your help. i already got it...