I've recently started working on an Image Upload web application in PHP, and I plan on sending an $_FILES variable to another form, after being taken from a previous form.
For example:
form1 has an <input type="file" name="image">. After that,
form2 takes it using $_FILES['image'] and wants to send it to form3 via $_SESSION['image'] = $_FILES['image'].
The problem is, after I try to move_uploaded_file() using that session variable, the file isn't moved into the directory. My upload directory (in which I store all the images) is empty.
That's how I tried moving the file:
$file = "upload/".$link.".".pathinfo($_SESSION['file']['name'], PATHINFO_EXTENSION);
move_uploaded_file($_SESSION['file']['tmp_name'], $file);
Don't worry about $link. That's just some "key" I use in my links (a way to auto-generate the links).
I also tried declaring another $_FILES variable and assigning it the value of $_SESSION['file'], and then use it in move_uploaded_file(), but still didn't work.
My question is: is it possible to correctly pass a $_FILES variable to $_SESSION? If yes, how does it come that it doesn't work in my case. What did I do wrong?
If you need more code and (or) information, feel free to leave a comment and I'll provide it to you as soon as possible.