Store filename in a session variable
Using Pure PHP Upload, how can I store the filename of the uploaded file in a session variable?
I simply want the files to be uploaded and filenames stored in session variables, no need to insert in a database table.
Answer:DISCLAIMER:
This is extra complimentary content which purpose is to show additional usage that is not part of the product, i.e. it suggests tips for extending the functionality of the product by the users themselves.
DMXzone does not take responsibility to support the suggested content to be fully compatible and working as intended and does not provide support for extended functionality which is not included in the current release of the extension.
It is highly recommended that only more advanced developers use it.
Storing the filenames in session variable is easy:
$HTTP_SESSION_VARS['filename1'] = $HTTP_POST_VARS['filename1'];
but you should do this only when the upload is in process so:
if (isset($HTTP_GET_VARS['GP_upload'])) {
$HTTP_SESSION_VARS['filename1'] = $HTTP_POST_VARS['filename1'];
$HTTP_SESSION_VARS['filename2'] = $HTTP_POST_VARS['filename2'];
}
Add this code at the end of the upload code
filename1 and filename2 are the form upload field name
Since PHP version 4.1.0 it is also posible to use $_SESSION and $_POST.
Also DMX 2004 uses $_SESSION and $_POST as default.
Comments
Be the first to write a comment
You must me logged in to write a comment.