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 9238849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:51:20+00:00 2026-06-18T07:51:20+00:00

I have a button that runs the below code. The csv file writes fine,

  • 0

I have a button that runs the below code. The csv file writes fine, but for some reason it is not downloading. Nothing happens, no errors. I have used the force download before and it has worked fine.

Any ideas?

    $csvContent = $this->dbutil->csv_from_result($query);

    $date = date('U');
    $filename = date('Y-m-d-Gis', $date); 

    if (!write_file("./reports/$filename.csv", $csvContent)) {
        echo 'Unable to write the file';
    } else {
        echo 'File written!';

        $data = file_get_contents("reports/$filename.csv");
        force_download($filename, $data); 

    }  
  • 1 1 Answer
  • 0 Views
  • 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-06-18T07:51:22+00:00Added an answer on June 18, 2026 at 7:51 am

    You should try $data = file_get_contents("./reports/$filename.csv"); instead 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically when a user clicks a button I have a javascript code that runs
I currently have a delayed task that runs whenever I click a button. Clicking
This code below is for a form that needs to save some values into
I have a application as below that runs as FullScreen.NoTitleBar: public class BrowserActivity extends
I have an android app that runs good in Android 2 , but when
I have button that a user selects and I pop up a AlertDialog to
I have a button that can have a focus css class associated with it
I have event Button that creates text box in run time. Private Sub Button1_Click(ByVal
I have a button that cause an image to display the image full screen
I have a button that I want to make disappear if anything is tapped

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.