HTTP Upload and Sessions

Home Download Demo Contact Us
Home
 :: About Us
 :: Services
 :: Contact Us
Products
 :: Rad SFTP
 :: Rad Upload
 :: MMS
 :: Print Suite
 :: Card Designer
Demo
FAQs
Partners
Press
Members
Buy Now

Identifying the owners of uploaded files.

Compressed File Upload

Developer FAQ

PHP Upload Configuration

Download

Online Documentation

This article describes how session information can be shared between the applet and your web application. Sessions are usefull when you need to identify which user of your web site is carrying out the file upload over.

Before we go any further it should be noted that many web developers believe that sessions and cookies are one and the same, in actual fact cookies are just another way of storing session data (though it is the most commonly used). Obviously this discussion is only applicable when Rad Upload is being used in HTTP mode.

Regardless of the mechanism in use there will always be a unique identifier associated with each session. The applet is capable of passing this information to the serverside handler.

PHP

Maintaining state with PHP is certainly a lot easier than with other languages, however there are certain pitfalls for the unwary.

In most installations of the PHP engine the session identifier can be encoded in the URL using the special identifier PHPSESSID. In some installation a different variable name may be used, you are can find the variable name with a call to phpinfo()

The first thing to do is to place a call to session_start() before your script produces any output. Calling session_start() after the script has produced some output is of no use. A common mistake is to have some blank space before the first php processing instruction (<? or <?php ). Please clean out your whitespace or your session information will be lost.

Next you need to pass this unique identifier to your server side upload handler. Please change your applet's url parameter to someting like the following:

<param name="url"
value = "http://radinks.com/upload.php?PHPSESSID<? echo session_id(); ?>">

In the last step you need to once again call the session_start() function in the server side handler (in the above example it's upload.php) before any output is produced. You can now access your saved data using the $_SESSION array. (See the full list of parameters)

JSP/Servlet

Howto pass session information with JSP and Servlets may appear less obvious than with other technologies. Most Servlet Containers use a variable name of jsessionid to store the unique identifier. The HttpServletResponse class does have a encodeRedirectURL() method which can be used to automatically add session data to a URL. However this does not add the unique identifier to the URL when cookies are being used.

The solution is to manually add the jsesionid variable to your server side handler's URL. Your code should look similar to the following.:

<param name="url"
value = "http://radinks.com:8080/upload;jsessionid=<%= session.getId() %>">

The code displayed above may be spread over several lines in your browser, when you cut and paste into your JSP page please make sure that it does not wrap in the middle of a variable name.

Note: This document is provided as an aid for developers, it should not be considered as an integral part of the Rad Upload documentation.

See Also : How to collect user input with an HTML form

 

  Quick Navigator }  
Learn More,   Online Demo,   Q & A,   Docs,  
Download,   Features & Pricing,   Source Code

 

 

Site Map  |  About us  |  Services  |  Contact Us  |  Members

Copyright 2006 Rad Inks (Private) Limited. All Rights Reserved.

Privacy Policy   |  Terms of Use