Using php APC and ajax http call, my file upload progress bar works fine but here is my problem::
file is uploaded by submitting form to a script upload.php which simply moves the uploaded file from temp location to a specified location.
upload_form.php has one form that includes the info about uploading file but HERE IS MY COMPLICATION:: this file upload is just a part of my other form, where a user is posting an article, hence user info, email, article title, article body bla bla are also being submitted along with the file(image file)
Because I need to process other info (user info, article body etc) on server side script, I do not want to move the uploaded file to specified folder just yet because if the uer aborts the submission of his article this uploaded file is just a waste to keep in the folder.
My Question is how long is an uploaded file kept in the temp directory by the server? OR, what is the proper mechanism to submitting an article that includes a file upload as well??
any help would be appreciated, thanks
upload_form.php
(working fine)
<form onSubmit="startProgress('<?php echo $uid; ?>');" action="upload1.php" method="post" enctype="multipart/form-data" name="upload" id="upload" target="upload_frame">
<input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="<?php echo $uid; ?>" />
<input type="file" name="file" id="file" />
<input type="text" name="tt" id="text" value="text value" />
<input type="submit" name="submit" id="submit" value="Upload!" />
</form>
<div id="pb_outer">
<div id="pb_inner"></div>
</div>
upload.php
if($FILES['file']['error'] == UPLOAD_ERR_OK)
{
$tmp = explode(".", $FILES["file"]["name"]);
$ext = $tmp[sizeof($tmp)-1];
$newFname = $POST['APC_UPLOAD_PROGRESS'] . "." . $ext;
$path = 'files/';
$path .= $newFname; //basename($FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'], $path))
{
// upload successful
echo "File uploaded\n";
}
}
getprogress.php
is called on by ajax httprequest to poll the uploaded amount of the file being uploaded,, which is displayed in upload_form page in 'pb_inner' div.