Uploading Files from Clients There are two mechanisms

Uploading Files from Clients There are two mechanisms that can be used by browsers for uploading files to the server: . Based on the HTTP PUT method . Based on the HTTP POST method The HTTP protocol provides three basic methods GET, PUT, and POST for accessing information from the web server. The GET method is used to fetch web pages. When GET is used to fetch dynamic pages, the form variables are passed as part of the URL. It is safe for the browser to fetch a page using the GET method as many times it likes the GET method should not cause any permanent change on the server. Some web servers have a limit on the length of the URL (mostly 1024) that they can handle, so GET should not be used to pass form data greater than this limit. The PUT method is used for updating information on the server. It requests that the enclosed data be stored as the requested URL on the server. The PUT method is used mostly for publishing pages. The POST method is used if requesting the URL will cause a permanent change on the server. For example, deleting a folder in a web based e-mail application. The browser should not execute the POST method again without getting user confirmation. The POST method sends all the form variables as part of the request body. The POST method is also used when lots of form data needs to be passed to the URL. Uploading Files with PUT A typical HTTP PUT request looks like this: PUT /path/filename.html HTTP/1.1 In this case the client would like the web server to store the contents of the request as the specified URL (/path/filename.html) in the web server’s URL namespace. The web server, by default, would not handle such a request. Rather it specifies a script to handle such requests. Web site specific policies for uploading files can be implemented in the specified script. For example, in Apache this can be done with the script directive (stored in httpd.conf). The following script directive means that you want the cgi script put.cgi to handle HTTP PUT requests: Script PUT /cgi-bin/put.cgi PHP provides support for writing PUT handlers. When PHP gets a PUT request, it stores the contents of the request in a temporary file, which is deleted after the request is processed. The temporary file name is stored in the $PHP_PUT_FILENAME variable, and the URL name is stored in $REQUEST_URI. This simple PHP script, for handling PUT requests, copies the uploaded file to the specified URL location in the web server’s URL name space: The PUT mechanism for uploading files is non-functional in the current implementations of PHP. You could monitor the status of this bug at http://www.php.net/bugs.php?id=10383. Uploading Files with POST HTML form elements allow users to enter the name of the file that will be submitted to the web server. This feature is implemented by recent versions of both Netscape and Microsoft browsers. A simple HTML form (uploadfile.html) for submitting the file looks like this: Page 249
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services

Comments are closed.