Reply to call to method

Your name:

Reply:


Posted by Duff B on 11/28/05 13:56

Hi,
this code perfectly works when I try to force the download of a file,
by calling it directly.



<?php

$file = "onefilename.txt";
if (!is_file($file)) { die("<b>404 File not found!</b>"); }
//
$filename = basename($file);
//
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
//
$ctype="application/force-download";
header("Content-Type: $ctype");
//
$header="Content-Disposition: attachment; filename=".$filename.";";
header($header );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$len);
@readfile($file);
exit;

?>



Now, I can't get this working as a method of a class:



function downloadFile($theFile){

$file = $theFile;
if (!is_file($file)) { die("<b>404 File not found!</b>"); }
//
$filename = basename($file);
//
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
//
$ctype="application/force-download";
header("Content-Type: $ctype");
//
$header="Content-Disposition: attachment; filename=".$filename.";";
header($header );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$len);
@readfile($file);
exit;
}


After instantiating the class, I call
instance.downloadFile("myFile.txt") but I get no prompt.

What am I doing the wrong way?

Thanks.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация