-
Change default download location
Hello,
I am struck with one problem, In my below code i am trying to download csv file from other server and wanted to save it on my root directory but it is going to save on My local Downloads folder. Is there anyway to change my download location?
I wanted to download it on my server not in my Downloads folder.
can any one help me?
<?php
$ok = true;
//echo "out";
//echo $_SERVER['REQUEST_URI'];
$name = substr($_SERVER['REQUEST_URI'],0,strrpos($_SERVER['REQUEST_URI'],'/'));
if( $ok )
{
$file_path = "http://www.bseindia.com/bhavcopy/eq200612_csv.zip";
$path_parts = pathinfo($file_path);
$file_name = $path_parts['basename'];
$file = @fopen($file_path,"rb");
//echo "In";
if ($file)
{
header("Cache-Control: public");
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");
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=\"{$file_name}\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($file_path));
while(!feof($file))
{
echo fread($file, 500*1024);
//echo readfile($file);
flush();
if (connection_status()!=0)
{
@fclose($file);
die();
}
}
@fclose($file);
exit;
}
else
echo "Invalid File Request";
}
?>
Thanks in Advance.
-
-
Hiya round,
Please encase your code in [CODE] tags 
I think this could help you.
Bernie
-
-
Bernie thanks for your reply,
I didnt get what you want to say.
Can you please explain?
Thank you.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks