چهارشنبه 9 بهمن 1387, 4:32 بعدازظهر
سلام به همه .کمک کمک کمک !!!!!11
کد امکان داونلود کردن یک فایل برای کاربر را می خواستم.(یک فایل 3gp )البته
من یک کد دارم :
کد امکان داونلود کردن یک فایل برای کاربر را می خواستم.(یک فایل 3gp )البته
من یک کد دارم :
<?php
//The location of the image.
$path = "images/winter.jpg";
try {
if (is_file ($path)){
if ($file = fopen($path, 'rb')) {
while(!feof($file) and (connection_status()==0)) {
$f .= fread($file, 1024*8);
}
fclose($file);
}
//Use the header function to output an image of .jpg.
$outputname = "myimage";
header ("Content-type: image/jpeg");
//This will force a download.
header("Content-disposition: attachment; filename=".$outputname.".jpg");
//print $f;
fpassthru($f);
} else {
throw new exception ("Sorry, file path is not valid.");
}
} catch (exception $e){
echo $e->getmessage();
}
?>
ولی error می ده:
Notice: Undefined variable: f in c:\Inetpub\wwwroot\Untitled-3.php on line 15
Warning: Cannot modify header information - headers already sent by (output started at c:\Inetpub\wwwroot\Untitled-3.php:7) in c:\Inetpub\wwwroot\Untitled-3.php on line 21
البته فعلا این کد را به صورت پیش فرض خودش اجرا می کنم که errorمی ده .می خوام errorرا رفع کنم ؟