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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:36:29+00:00 2026-05-20T04:36:29+00:00

In Codeigniter, we can use the force_download($file_name,$data) function from the download helper to force

  • 0

In Codeigniter, we can use the force_download($file_name,$data) function from the download helper to force the browser to download a file.

But this is not what I need, I would like Codeigniter to respond a http header with the MIME type that the file corresponds to, so that the browser may or may not download the file, depending on whether there is an application registered for that MIME type on the client machine (if there is one, that application will open that file).

Is there a way of doing this with Codeigniter?

Many thanks to you all.

  • 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-05-20T04:36:30+00:00Added an answer on May 20, 2026 at 4:36 am

    No, you cannot do that with Codeigniter.

    Generally speaking, with server-side technologies like PHP, you can only send content to the client, not directly interact with the client. It is up to the client to do what they wish with whatever piece of content you send them. Even with client side tools like javascript, (thankfully) you can only have limited interaction with the client machine. What you are wanting to do is allow a website to (automatically) upon visiting, download a piece of software, and execute it on the client machine…

    that’s called malware… (brought to you by the makers of ActiveX)

    Above was in direct response to

    “…so that the browser may or may not download the file, depending on whether there is an application registered for that MIME type on the client machine (if there is one, that application will open that file).

    UPDATE

    You can set the mime type through plain php header manipulation. The following example is taken directly from the php header() documentation as the first example.

    <?php
    // We'll be outputting a PDF
    header('Content-type: application/pdf');
    
    // It will be called downloaded.pdf
    header('Content-Disposition: attachment; filename="downloaded.pdf"');
    
    // The PDF source is in original.pdf
    readfile('original.pdf');
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in codeigniter you can use wildcard to reroute. i never heard the word wildcards
You can use the URL helper in Code Igniter to load CSS and Javascript
In Kohana/CodeIgniter, I can have a URL in this form: http://www.name.tld/controller_name/method_name/parameter_1/parameter_2/parameter_3 ... And then
Im using JQUERY + CodeIgniter. I can't seem to get the returned data to
I followed this tutorial: https://github.com/EllisLab/CodeIgniter/wiki/PDF-generation-using-dompdf However, I can't seem to set the path right.
CodeIgniter allows access to POSTed data via: $this->input->post('input_name'); where 'input_name' is the name of
I'm quite new to CodeIgniter and I'm trying to re-use the $data I pass
hi i am using codeigniter , i use the insert_batch function . i have
Can I use Codeigniter classes without implementing the whole mvc pattern the same way
I'm making the switch from CodeIgniter to Symfony 2. Can someone please give me

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.