Jump to content

Recommended Posts

I'm new here, so please excuse me if I happen to do something wrong at first, I'll learn.

I run a file host and am re-writing the scripts to maintain ease of use for myself and the users. Now I am using header() to display the files, and I have noticed that without applying header('Content-type:whatever') that in some browsers, the file is not recognized as the right format.

But if I apply:

[code]header('Content-type: application/octet-stream');
header('Content-Disposition: inline; filename=realFile.exe');
readfile($theFileURL);[/code]

it works correctly. [b]But my question is:[/b] can I just use application/octet-stream for all file types (exe, jpg, bmp, zip, anything) and have it work correctly with all of them?

I tried:

[code]header('Content-type: application/octet-stream');
header('Content-Disposition: inline; filename=realFilename.jpg');
readfile($thefileURL);[/code]

and it worked correctly, displaying the image and all. In IE, firefox, and Opera.

So I am wondering whether I need to make it so it does define the correct mime-type for all the file types or if I can just use the application/octet-stream for all of them?

Oh yes, and with Content-Disposition, can anyone clearly explain the difference between using 'inline' and 'attachment' to me? I have noticed that using 'attachment' usually steers more towards having to download the file, but can I just use 'inline' for all files because it seems to work correctly (tested in IE, Firefox, Opera)?

Please excuse the long first post, but it's late and I'm just trying to get a few problems out of the way.

Thank you in advance.

Edit: I just realized I stated that I tried using the method and it worked, and yet I still come here and ask questions about it. But I'm wondering if you think it will work with stability or if it just doesn't seem like a good idea in general?
Link to comment
https://forums.phpfreaks.com/topic/10830-download-as-applicationoctet-stream/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.