POST $_FILES

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Rassinger

    POST $_FILES

    Hi!

    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!
    Mike
  • Good Man

    #2
    Re: POST $_FILES

    Michael Rassinger <dj.cyberdance@ gmx.atwrote in
    news:d4841$45f8 5dd6$51df179a$8 208@news.inode. at:
    Hi!
    >
    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!
    Mike
    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.

    Comment

    Working...