Jump to content

File download


joecooper

Recommended Posts

im trying to think up a way where the user can download a file, without knowing the download link, (so that i can make a que system ect...). Ive tryed to use include("file.exe"); as a test.. didnt think it would work. but it has the same idea, grabbing a file without the user knowning where it is located.

Any code examples?
Link to comment
Share on other sites

The forums are acting funny today, so I'll do what I can:

[code]$ name = "path/to/f ile.txt";

$ type = m ime_content_type($name);
$ size = f ilesize($name);

h eader("C ontent-length: $size");
h eader("C ontent-type: $type");
h eader("C ontent-Disposition: attachment; f ilename=$ name");
echo f ile_get_contents($ file);[/code]

remove the random spaces I've put throughout
Link to comment
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.