View Upload Log || GET_URL || PUT_FILE || Description || SREhttp/2 Demos

## SREhttp/2: Uploading Files
This page demonstrates two SRE_UTIL utilities that will upload files to this server -- either from another web server, or from you own computer

### GET_URL : Transferring a file from a Server

You can use this to transfer a file to this web server, from a different web server.

Enter the URL to retrieve: |
Username & password: | enter only if needed
What name should it be saved as: | if you include `?`s, a unique filename will be generated leave this blank and a name will be automatically generated please use a relative file name
Optional comment |

Top

### PUT_FILE: Transferring a file from a Client

This form can be used to upload a file, from your computer, to this web server.

Enter the name of the file to send: |  |
What name should it be saved as: | Check here to try to use the file's name if you include `?`s, a unique filename will be generated leave this blank and a name will be automatically generated please use a relative file name
Optional comment |

Top

### Description of SREhttp/2 File Upload Utilities

SREhttp/2 provides two built-in "actions" for uploading files, plus one HTTP method for uploading files, plus one HTTP method for deleting files. Each of these has its own advantages and disadvantages:

1. GET_URL: An addon for uploading files from another HTTP server
   - Requires that the client has ready access to an HTTP server.
   - Given this access, uploading is quick and easy.
2. PUT_FILE: An addon for uploading files from the client's own machine
   - Requires that the client be using a browser that supports the `type=file` FORM attribute (such as NetScape 2.01 and above).
3. The PUT method.
   - Requires that the browser (or other software) know how to issue a PUT method HTTP request. The DOGET.CMD program, that comes with SRE2003, can be used to make PUT method requests.
4. The DELETE method. This can be used to delete files from your server. As with the PUT method, it requires a browser that knows how to issue DELETE method HTTP requests (DOGET.CMD can also be used for DELETE method requests).

General Usage notes:

1. GET_URL.

   Set up a URL with the GET_URL action, followed by the URL of the file you want to get, and the "local name". The request selector should look like: `GET_URL?url=http://a_url&file=relative_file_name`

   For example:

   - `GET_URL?url=http://www.pc.com/price.lst&file=pcprice.1`
   will copy price.lst (on the server at www.pc.com) to a file named `PCPRICE.1` (in the `SREHTTP2\UPLOAD` directory).

2. PUT_FILE.

   Create an HTML FORM with a `type=file` attribute. For example:

       <FORM enctype="multipart/form-data" ACTION="/put_file" METHOD="post">
         Send this file <INPUT TYPE="file"  name="relative_filename">
         <INPUT TYPE="submit" VALUE="send file">
       </FORM>

3. The PUT and DELETE HTTP methods are, by default, not permitted. To allow PUT or DELETE methods, you must include a PUT or a DELETE permission for the appropriate entry (one that matches the requested selector ) in the (possibly host-specific ATTRIBS.CFG file.

4. As with the more commonly used GET and POST methods, selectors in PUT and DELETE method requests are relative to the data directory (or to a local virtual directory).

5. To allow uploaded files to overwrite pre-existing files with the same name, you need to set the PUT_OVERWRITE parameter, or the PUT_OVERWRITE selector specific option.

6. By default, uploaded file are stored in files relative to the UPLOAD_DIR directory (which is set in SRE_UTIL.CFG).
   However, files can be written to a virtual directory, provided a PUT permission has been granted.

   For example,

   - if a `PUT` request has request selector of `/TODAY/OUTPUT.1`,
   - an entry in ATTRIBS.CFG has the rule: `/TODAY/*`,
     and defines a virtual directory of `D:\WWW\HISSTUFF\NEW`
   - and a `PUT` permission has been granted
   - then, `D:\WWW\HISSTUFF\NEW\OUTPUT.1` will be created.

     In contrast,

   - if there was no entry (in ATTRIBS.CFG) with a rule that matches `/TODAY/OUTPUT.1`
   - then the contents of this PUT request will be stored in the `TODAY` subdirectory of the UPLOAD_DIRECTORY -- that is, the PUT permission is not needed.

#### PUT_FILE and GET_URL usage Notes

- Files must be less then UPLOAD_MAXSIZE in kbytes size; and there must be UPLOAD_MINFREE kbytes free (in the UPLOAD_DIR directory) after the file is uploaded. If either condition can not be met, the file will not be uploaded.

- If you do not specify a local file name, SREhttp/2 will create a "unique" file name in your UPLOAD_DIR directory.
  You can specify "partially random" filenames by including ? characters in the filename. SREhttp/2 will attempt to create a unique file name by appropriate substitutions of the ? character(s). For example:
  - if filename=ABC??.TXT,
  - and ABC01.TXT exists,
  - then SREhttp/2 will use ABC02.TXT.

- For all uploads, a short status report on success of the upload operation is written to the UPLOAD_LOG file.

- For GET_URL: You must completely specify the URL (including the http:// portion).

- For PUT_FILE: Browsers that do not support the `type=file` FORM attribute will send back garbage (that will be ignored).

- For PUT method uploads, size limits are not imposed.