Advanced upload example

This example adds the record to "Titles" table including a reference to uploaded cover page image. Here is the code for page containing the form:

<title>Add Titles</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-us">
<form action="titlesAdd.wbsp" method="POST" align="center" id="addForm" ENCTYPE="multipart/form-data">
<table border="0" cellpadding="0" cellspacing="0">
<td align="right"><input type="text" name="WBF_Title" value size="20"></td>
<td>Year Published&nbsp; </td>
<td align="right"><input type="text" name="WBF_Year Published" value size="20"></td>
<td align="right"><input type="text" name="WBF_ISBN" value size="20"></td>
<td>Publisher </td>
<td align="right"><select name="WBF_PubID" size="1">$wbsr[]</select></td>
<td align="right"><select name="WBF_AU_ID" size="1">$wbsr[]</select></td>
<td>Book cover (image)</td>
<td align="right"><input type="file" name="WBF_imageURL" size="20"></td>
<td align="right"><input type="submit" name="sButt" value="Add new title"></td>

and titlesAdd.wbsp file should look something like this:

In this example, when visitor enters the values in all form fields (including the image file to be uploaded using WBF_ImageUrl) and submits the form, WBSP will accept the data and:

  1. Check the Upload variable for current virtual host in wbsp.ssc file
  2. If uploading is enabled WBSP engine will read the WB_AllowMultipart variable from WBSP file titlesAdd.wbsp
  3. Since it exists and is set to True WBSP engine will process the uploaded file (e.g. mycover.gif)
  4. First WBSP checks if the file size is less then or equal to the number specified in variable WB_MaxFSize (24576 bytes in this example)
  5. If file size is OK, WBSP saves the file in directory specified in variable WB_UploadDir (directory images in servers document root)
  6. If file with same name already exists it will generate unique file name (because WB_Overwrite is set to False) for uploaded file
  7. Next WBSP changes the value of form variable WBF_ImageURL to WB_BaseURL+name of the saved file (in this example /images/mycover.gif)
  8. WBSP writes the log record in log file specified in variable WB_UploadLog (in this example file upload.log located in same dir with file titlesAdd.wbsp)
  9. After this WBSP engine will continue processing the WBSP file to complete the Add record command (specified by WB_Command=A) as it was ordinary form, with the exception of the value of table field imageurl which will have value /images/mycover.gif (relative URL of the uploaded file, and not the file itself).