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

  • SEARCH
  • Home
  • 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 8309061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:59:43+00:00 2026-06-08T18:59:43+00:00

In my php code, I am retrieving rows from a mySQL db and saving

  • 0

In my php code, I am retrieving rows from a mySQL db and saving them in to a CSV file. I am hard coding the file name in code. The algorithm is simply as follows:

1. Allow user select excel file.
2. Retrieve rows from table, separate column data with commas and build up strings through concatenation.
3. put the build up into the selected file.
4. Close the file.

However, I wish to show a Save As dialog box for the user to choose the file before I save the built CSV string into the file. The suggestions that I have seen all talk about making it look like a download however in a download the file is already built up before the user saves to local machine. In my case, the file has to be selected first.

I also want the application to be portable if it is moved from a machine whose primary partition is labelled C: to one that is labelled D: so I won’t need to hard code. Thanks.

  • 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-08T18:59:44+00:00Added an answer on June 8, 2026 at 6:59 pm

    To cause browsers to download a file (versus just opening it when it’s a known MIME type), you can set the following headers:

    • Content-disposition: attachment; filename=fname.ext

    I don’t believe there is any way to force browsers to prompt with a Save-As dialog. Each browser handles this differently and it’s normally a local user setting. (i.e. Automatically download to default folder, prompt every time, etc.)

    As an alternative, perhaps suggest to your users that they use “Right Click -> Save As…” when they need to clearly specify the download file location and name.

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

Sidebar

Related Questions

I have used following code for retrieving content from a csv file. <?php $fo
I need help with some PHP code. I am retrieving data from a MySQL
Is there really a way to do this ? Retrieving raw .php file from
My PHP code is: $query=select company_name from company_names where cik=.$cik; Which on printing gives
My PHP code $dom = new DOMDocument(); @$dom->loadHTML($file); $xpath = new DOMXPath($dom); $tags =
I've got a piece of PHP code retrieving my last tweet : $twitterrequest =
i have a problem when it comes to retrieving value from jQuery to php.i
With a CMS (PHP/MySQL) that's getting bigger and bigger and its code harder to
Hi guys i am retrieving data from php using ajax , what i am
I am retrieving data via JSON and PHP from a URL. I am having

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.