upload.pl |
- NAME
- DESCRIPTION
- EXPECTED PARAMETERS
- EXAMPLES
- DEPENDENCIES
- CAVEATS
- METHODS
- FILES
- BUGS
- ERROR HANDLING
- SEE ALSO
- AUTHORS
- NOTES
NAME
upload.pl - upload an image to a user/script specified directory and save the related image information to a database.
DESCRIPTION
upload.pl is a short script which uploades images and saves the related information to a database by using the Perl moduleDatabase.pm
. It is designed to be used as a CGI script called by an html document which supplies the parameter values for the script.
EXPECTED PARAMETERS
These parameters are expected to come from input fields of the same name contained in the html calling the script, whether it be hidden fields or form input.
- $baseDir - Path to upload destination. Note: NO trailing slash.
- $allowAll - Allow all file types to be uploaded? yes/no (lowercase).
- @fileType - A list of file types to be allowed (assuming not all are allowed). This currently set within the script.
Example:
@fileType = ("jpg", "gif");- $donePage - The page you wish it to forward to if successful.
- $errorPage - The page you wish it to forward to if not successful.
- $file - Full path to file to be uploaded.
- $dir - Specific directory/category that file is to be uploaded to. This value will be appended to the base directory to get the full path where the image will be saved to.
- $default - Default image directory if no directory has been selected.
- $xml - XML database file. This must have the extension
.xml
and it must include the full or relative path to the xml document.- $xsl - XSL to be referenced by the XML document. This must have the extension
.xsl
. This need not include the path to the file as long as the xsl is in the same directory as the xml.- $dtd - DTD to be referenced by the XML document. This must have the extension
.dtd
. This need not include the path to the file as long as the dtd is in the same directory as the xml.- $title - Title of the image.
- $caption - Caption of the image.
- $generatedBy - Name of person who generated the image.
- $sitePath - ??? Currently unused parameter.
- $url - Link to related research.
EXAMPLES
Here is some sample html that could be used to call the script and pass it the appropriate parameters:
<form method=post enctype="multipart/form-data" action="../../cgi-bin/upload.pl">
<table width="550" cellspacing="0" cellpadding="10" align="center">
<input type="hidden" name="donePage" value="http://dante.sci.utah.edu/develop/simpson/scratch/file_upload/submit_select.html" />
<input type="hidden" name="errorPage" value="http://dante.sci.utah.edu/develop/simpson/scratch/file_upload" />
<input type="hidden" name="xml" value="../scratch/file_upload/database/images.xml" />
<input type="hidden" name="xsl" value="images.xsl" />
<input type="hidden" name="dtd" value="images.dtd" />
<table>
...Assign the rest of the input parameters using input tags... </table>
</form>
Example html form pages which use
upload.pl
:
Radio Buttons
Drop Down Menu
Hidden Fields
Text Box
DEPENDENCIES
Uses modulesDatabase.pm
,CGI
andCGI::Carp qw(fatalsToBrowser)
.Database.pm
in turn uses modulesXML::Simple
,Data::Dumper
, andIterator
.
CAVEATS
This script does not yet include image resizing. Only one image may be uploaded at a time. File types are tested based on the file extension, which may be a problem for mac files which do not have file extensions.
METHODS
Upload() - If file is of acceptable file type and destination directory is valid, uploads file to $baseDir/$dir and writes its info to the database.
FILES
To be fully functional, needs to work with the following files:Optional additional scripts:
- upload.pl (located in cgi-bin directory)
- Database.pm (located in cgi-bin directory)
- some xml file
- some xsl file (located in same directory as the xml)
- some dtd file (located in same directory as the xml)
- searchDB.pl (provides an interface to Database.pm to for searching the image database)
BUGS
To report a bug, send mail to Jennifer Simpson at (simpson@cs.utah.edu)
ERROR HANDLING
Errors result in an error message being sent to the browser as well as the sever error log. Error conditions include:
- Permission codes violated
- File already uploaded to a given directory
- Directory not found
- No image file submitted
- Incorrect file type
SEE ALSO
upload.pl
Design document forupload.pl, Database.pm
, andintializeDB.pl
.
Documentation ofDatabase.pm
.
Html form pages which use this script :
Radio Buttons
Drop Down Menu
Hidden Fields
Text Box
AUTHORS
Jennifer Simpson (simpson@cs.utah.edu) and Erik Jorgensen (erikj@cs.utah.edu).
NOTES
Database.pm
needs to be put in the same directory asupload.pl
. The code forDatabase.pm
can be found at Database.pm