Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Michael Rassinger
March 14, 2007, 8:50 pm
rate this thread
I am facing the following problem:
I have a PHP-script on page A that receives a file from an HTML-form. I
need to immediately forward this file to another page B.
On page A currently I forward the user (under certain circumstances) to
page B using
header ("location: page_b.php");
But unfortunately the file that was posted to page A is lost. Is there a
way to forward the file to page B so that I can use the superglobal
$_FILES variable on page B?
I tried a very bad hack with sessions:
On page A:
$_SESSION["files"] = $_FILES;
On page B:
$_FILES = $_SESSION["files"];
I didn't really expect this to work - unfortunately it does not because
the server deletes the temporary file immediately. Well, I could try
copying the temporary file to a different filename but I believe there
is a simpler way by just adding the file again to the header?
Any suggestions on this? Thanks in advance!
Re: POST $_FILES
As you suggested, I think the best way it to copy the file to a temp
directory, and pick up the file on your "b" page.
You don't want page_a having to re-upload/re-send the files to page_b
anyways - uploading a file more than once is pretty wasteful, in terms of
server resources and time.