Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6202005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:39:17+00:00 2026-05-24T04:39:17+00:00

I am looking for some general guidance on this one… I have created a

  • 0

I am looking for some general guidance on this one…

I have created a PHP script that uses cURL to download a csv file. Currently, it downloads the file to my computer when I run the script. I would like to amend the download path to route it to a directory on my web host. Is there any easy way to do this with PHP?

Here is a quick summary of the PHP script that downloads the CSV file:

<?php 

$ch = curl_init(); 
//this is where I submit the form to download the csv file...
curl_close ($ch);  

header("Content-Disposition: attachment; filename=file_I_am_downloading.csv"); 
header("Content-Type: application/octet-stream"); 
readfile("http://www.example.com/file_I_am_downloading.csv");
?>

To sum this up, I would like the script to be amended so that when I run this PHP file it downloads ‘file_I_am_downloading.csv’ to a specific directory on my host rather than first downloading to my computer. Thank you for your time and any direction you can provide is much appreciated.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:39:18+00:00Added an answer on May 24, 2026 at 4:39 am
    $ch = curl_init();
    .... curl setup
    $data = curl_exec($ch);
    if ($data === FALSE) {
       die(curl_error($ch));
    }
    
    // do this, instead of the header/readfile business.
    file_put_contents('/some/path/on/your/webhost', $data);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a common scenario that I am looking for some guidance from people
I'm just looking for some general advice with this one please. My WCF WebMethod
Looking for some guidance on a WCF service I’m prototyping. I have a WCF
I'm looking for some general guidance as to how to return a user back
I'm looking for some general guidance on serializing objects in a database. What are
I am looking for some general feedback here. I have a very simple application
Apologies if this question sounds a bit generic. I'm just looking for some general
I am developing an app and am looking for some general guidance: The app
Looking at the Cordova Docs , it seems that only some general information is
Looking for some general advice here. Option 1. Would it be best to have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.