Results 1 to 3 of 3

Thread: Change default download location

  1. #1
    Join Date
    Apr 2012
    Posts
    85
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default 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.

  2. #2
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    Hiya round,
    Please encase your code in [CODE] tags
    I think this could help you.
    Bernie

  3. #3
    Join Date
    Apr 2012
    Posts
    85
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Bernie thanks for your reply,

    I didnt get what you want to say.
    Can you please explain?

    Thank you.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •