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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:23:09+00:00 2026-06-02T23:23:09+00:00

I am new to programming, just learning it at school, but i want my

  • 0

I am new to programming, just learning it at school, but i want my users download some excel files from my homepage. The following code isn’t working, it only displays it in the browser and not forcing a download dialogue.

How can i solve this problem?

The link should be: http://myurl.com/download.php?fileid=1 or http://myurl.com/download.php?fileid=2 and so on.

<?php
switch ($_GET["fileid"]) {
    case 0:
        $file = "files/mon.xls";
        break;
    case 1:
        $file = "files/uru2.xls";
        break;
    case 2:
        $file = "files/oppo23.xls";
        break;
}
readfile($file);

Thanks for your help!

  • 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-02T23:23:14+00:00Added an answer on June 2, 2026 at 11:23 pm

    You have to use header. Like you can read on the php manual, its for your file:

    <?php
    header('Content-type: application/xls');
    header('Content-Disposition: attachment; filename="downloaded.xls"');
    readfile($file);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to programming but had some spare time and just got a
I am new to haskell and just learning the fun of functional programming. but
So I'm really new to programming, I just started learning Python yesterday and I'm
I'm very new to programming and I'm just starting to learn VBA with excel.
Am new to android programming, just started learning it the past 6 weeks and
I am new to functional programming and just switched from haskell (Didn't like it
I'm completely new to programming on the Android platform but I'm interested in learning
I am just new to programming in Unix and have a small issue that
I'm new to C programming and I just came across this program and got
i'm just new to iOS Programming, so appreciate for any help. I'm trying to

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.