Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    42
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Question what is exactly mime type for .PHP file?

    i found many ways to force download in PHP by googling.
    but i difficult to force download PHP file. I've searched mime type for php but nothing, just asp (text/asp).

    what is mime type for php file so i can force download .php file?

    thank you.

  • #2
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Are you trying to offer a php file for your users to download? Or are you trying to force a download of some media file?

    Typically you are trying to force a download of a zip file or a movie file and you need the mime type of those files. You don't need the mime type of the php file unless you are offering php files to download.

  • #3
    Regular Coder croatiankid's Avatar
    Join Date
    Jan 2006
    Posts
    665
    Thanks
    1
    Thanked 12 Times in 12 Posts
    If I remember correctly, the application/octet-stream MIME type will give a download prompt in all browsers.

  • #4
    New Coder
    Join Date
    Jun 2007
    Posts
    42
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Are you trying to offer a php file for your users to download? Or are you trying to force a download of some media file?

    Typically you are trying to force a download of a zip file or a movie file and you need the mime type of those files. You don't need the mime type of the php file unless you are offering php files to download.
    I offer php file to be downloaded. How could I do this?

    If I remember correctly, the application/octet-stream MIME type will give a download prompt in all browsers.
    i found that application/octet-stream is used by EXE file. can it used to php file too?

  • #5
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,027
    Thanks
    2
    Thanked 315 Times in 307 Posts
    Trying things is a great way of learning what works and what doesn't and it is often the quickest way to get an answer.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #6
    New Coder
    Join Date
    Jun 2007
    Posts
    42
    Thanks
    11
    Thanked 0 Times in 0 Posts
    ok, i'll try it. thank you.

  • #7
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    The PHP MIME type is application/x-httpd-php, if anyone's actually interested.

  • #8
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,631
    Thanks
    0
    Thanked 648 Times in 638 Posts
    It isn't supposed to be the MIME type that defines whether something displays in the browser or is offered for download. The only time that is supposed to have an impact is where the browser is not able to handle the MIME type specified.

    To specify that a file is supposed to be offered for download you are supposed to use:

    Content-Disposition: attachment;
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •