Jump to content

[SOLVED] Headers stuff


AV1611

Recommended Posts

I have a form that when submitted goes to a processor that does this:

 

<?php
header('Content-type: application/vnd.ms-word');
header('Content-Disposition: filename=file.doc');
echo "This is a variable: ".$_POST['blah']."\n";
//etc...
?>

 

The form submits and the file is downloaded no problem.

 

How can I make it so the page also forwards to a new page.

 

If I add

header('Location: newfile.php');

 

It forwards but no file is downloaded.

 

Help.

 

 

Link to comment
Share on other sites

Providing the readfile function doesn't do an exclusive lock on the file (which it shouldn't because it's doing a read operation) then you will be fine. 2 clients can read the same file at the same time. Files only usually get locked (on linux) when they're being written two or explicitly made to.

Link to comment
Share on other sites

Sorry,

 

What I meant was:

 

If I have to take the form, write the variables to the file, then download the file and forward to another page, and two folks do that at the same time, how do I make sure that the file was not changed with the other persons variables?  or am I being too careful?

Link to comment
Share on other sites

Assuming the file you're generating is dynamic (i.e. contains variables written by the user) and is created on the fly by PHP then the best option is to create a temporary file with a random name and delete it once it has been downloaded to the user.

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.