|
Content Management
Like every typical CGI application SqlDBU manipulates data straight on the
server. However SqlDBU supports data file uploading as well. A typical case are images and other multimedia files associated with records stored in the database. Usually those records just contain references (names) to files like that, which can be easily used for HTML tags like <img src=...>.
SqlDBU combines online database maintenance of these file names with the
appropriate file uploads to the server. This can be achieved by customizing
the already mentioned entry FORMVIEW=..., where the appropriate file upload field should be defined, e.g:
FORMVIEW=<input name="myname" size="60" type="file" \
maxlength="100000" accept="text/*">
In order to manage the store and upload operation correctly SqlDBU requires additional information like the name of the file used for the database entry and the target directory. These arguments can be delivered as hidden
arguments while SqlDBU assumes following name convention:
-
REMOTE<Column_Name>
-
NAME<Column_Name>
Sample:
Table bug designed for bug tracking (see chapter SqlDBU in action -
Simple Bug Tracking System) contains the column FILES, where names of files containing additional information can be stored to. Such a file describing
the problem can be a screen shot, code sample or zip archive with all
relevant files.
Setup sqldbu.ini contains following section in order to maintain database
entry bug.FILES in conjunction with appropriate file upload and download:
[BUG.FILES]
CAPTION=Images or Code Samples
BROWSEVIEW=
FORMVIEW=<a href="/cgi-bin/sqldbu?action=Download&file=-FILES-&id=-ID-"> \
-FILES-</a> \
<input type="hidden" name="REMOTEFILES" value="./bugs">\
<input type="hidden" name="NAMEFILES" value="bugs"> \
<i>Neu: </i><input name="files" size="40" type="file" \
maxlength="100000" accept="text/*">
Table bug can be used for communication within a team of (software
or web site) developers distributed around the world. Team member which
covers a problem (bug) during the project development process documents it
by creating a new entry for table "bug". Based on the defined column he will be able to upload the appropriate file (or file archive) for this problem to the Bug web site by a couple of muse clicks to his browser.
SqlDBU automatically stores the file name to column FILES of the newly created row. After saving the new entry all team members can download the file by clicking to the defined HREF tag.
Note: When processing http uplaod by POST request content and file name a part of information given to the appropriate CGI script.
When the data is sent, the original file name (including the full path) of the file as it was on your computer is sent to the CHI script. SqlDBU is free to save the file as anything it wants.
Therefore it needs the target directory for the uploaded file (REMOTEFILE)
and the entry name prefix (NAMEFILE) for the database entry pointing to
that file. NAMEFILE could be left empty, which means the naked file name (no path
information) will be saved to the table. In the sample above all files end up
in directory bugs, which is an immediate subdirectory of script root
(SqlDBU's home directory). All table entries will be prefixed by bugs/.
When uploading file bug1.zip table entry bugs/bug1.zip will be generated.
Value REMOTEFILE will be treated by SqlDBU relative to it's own directory (usually cgi-bin). Interpretation of NAMEFILE on the other hand (e.g. entry bugs/bug1.zip) can differ depending on how this expression is finally used:
-
When using the raw table entry as hyperlink means, that the appropriate file must be located in a subdirectory below the document root, e.g. wwwroot/bugs/bug1.zip: <a href="-FILES-">-FILES-</a> For this case value REMOTEFILE should have been adjusted, e.g. to value ../bugs, depending on how document root and binary root are located to each other.
-
When using the table entry as indirect hyperlink via a download script action it will point to a directory below the script root, e.g. cgi-bin/bugs/bug1.zip: <a href="/cgi-bin/sqldbu?action=Download&file=-FILES-&id=-ID-">-FILES-</a>
In general SqlDBU's Content Management Features can be tailored to both
directory trees, script and document root. It finally depends on the
Web Design and maybe the provider's security requirements which way to go.
Back
|