Jump to content

Recommended Posts

With code similar to this:

<?php
header('Content-Type: application/msword');
header('Content-Disposition: attachment; filename=filename.doc');
readfile('/not/in/web/root/word.doc');
?>

the user gets a desired doc, after I verify they can have it. In other words, they call my program, access.php, with something like "access.php?FN=word.doc", it checks their id info, then if OK it echoes the file back. All well and good, except that the file is returned (obviously) as "access.php". I don't want to write the file to a temporary location and give them a link to it, because then I'd have to make sure it gets deleted quickly - I want to control access to the files, so writing them to a known location and leaving them there is no good.  Is there a way to change the filename the requester gets? Like force it do be "word.doc", as in this example?  Best would be to trigger their download prompt, so they get to choose where to save it. etc. Can I stream it back as a ZIP? Would that be a decent approach?  But that still doesn't help the file name problem...  I think I'm missing something obvious....

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.