Simple upload example

The upload process functions like this – visitor sends the file to the server using multipart form (enctype="multipart/form-data"). WhizBase first checks if file upload is enabled in current virtual host setting (file wbsp.ssc). If it is not, WBSP will generate error and terminate processing of the WBSP file. If file upload is enabled, it checks if the WB_AllowMultipart variable is set to True in the current WBSP file, and if it is, WhizBase reads settings from Upload section of same file and process uploaded files (every multipart form can upload more than one file at the time).
When WhizBase receives all files it saves them following the instructions from Upload section and replace values of the multipart fields (fields that had contained the uploaded files) with URL of saved file, and then it process the WBSP file as any other.  Multipart form must use POST method.

Here is a very simple upload example (please read the comments in source code below):

[FormFields]
WB_AllowMultipart=T #*Allow this wbsp file to accept uploaded files*#
WB_Command=R
[Upload]
WB_Disallow=![jpg,gif] #*disallow uploading of any file type but jpg and gif*#
WB_UploadDir=/upload/ #*destination directory name (where uploaded files will be saved)*#
WB_BaseURL=/upload/ #*path that will be added to file name to reference the URL of the uploaded file*#
WB_Overwrite=F #*if set to false WhizBase will generate a unique name for newly uploaded file if file with same name already exists in upload directory*#
WB_MaxFSize=102400 #*Maximum size in bytes for single file that will be accepted by WhizBase*#
WB_UploadLog=upload.log #*name of log file where WhizBase will keep track of all uploads received by this file*#
<!--WB_BeginTemplate-->
<html>
<head>
<title>$wbif["$wbv[image]"=""|Upload file|File uploaded]</title>
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
$wbif["$wbv[image]"="" #*check if file has been uploaded*#
|
#*If not ($wbv[image] is empty) show the upload form*#
<form action="$wbe[script_name]" method="post" ENCTYPE="multipart/form-data">
Select file (*.jpg;*.gif - max. 100KB): <input type="file" name="image" size="20"> <input type="submit" name="sButt" value="Upload">
</form>
|
#*If file is uploaded ($wbv[image] contains URL to file) then display a link to uploaded file*#
Open uploaded image<br><a href="$wbv[image]" target="_blank">$wbv[image]</a>
]
</body>
</html>