ok i have a php file that uploads image. it consists of <input name="uploadedfile" type="file"> and a "continue" button. so when the user click continue, it validates and check for valid image file. If is successful, then it does not immediately save the image into the server but it goes to order.php whereby user key in their particulars. Therefore, i acutally though of saving the upload image path into sessions. So once the order.php is through, i will save the user particulars into mysql and upload the image into the server. this is what i do:

uploader.php

<?php
session_start();

$target_path = "Upload/$id.JPEG";
$_SESSION['imgPath']=$target_path;
if(!ereg("image",$_FILES['uploadedfile']['type']))
{
	header("location:error.php");

}
else
	header("Location: order.php");
?>

However, when i tried to upload the image in order.php it wont work. This is my coding:

order.php

<?php
session_start();

$custQuery = "INSERT .............";
mysql_query($custQuery);
move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $_SESSION['imgPath']);

    ok man there aint a reply. anyone have any idea??? if i were to upload an image, how do i store the image in a temp file to be uploaded later in a different file?

      When the file is uploaded the first time, save it in a directory called temp/ Then remember the filename in the session variable. When they get to the order page and they enter their details (I assume you are talking about determining if their payment was successful), then you move (mv) the file out of temp/ and into the saved/ directory since you know the filename from the session variable. You can periodically delete files from the temp/ directory that are over a few days (or even hours) old.

      You could probably convert the binary file to a string and store it in the session variables with base64encode or something like that... but I don't see any reason to do that. It's a waste of RAM - especially if you have multiple people surfing your site at the same time.

      Or you could have them upload the file AFTER they have entered their details (or successfully paid, or whatever).

        Write a Reply...