What about images?
July 10, 2000
Occassionally a writer may include an image with the article. Using the
system as it is now, however, will not upload the images along with the
document. You have to do these separately. This is a simple
matter.
The first step should be to build an image tables, tblImages. This
table should store the following info:
| tblImages |
|
IID |
Unique ID to keep track of records |
Autonumber |
|
Filename |
The filename of the image |
Text |
|
DocumentID |
The document in tblFiles that this image belongs to |
Number |
|
Fixed |
Checks to see if correct image has been uploaded |
Boolean (Yes/No) |
While these are the only required fields, you may also store the size
information, as well as the page numbers that each image belongs to.
The upload process is simple. You'll have to go through the text of the
document and find any images, ie, search for
<img src="blah"> For every one of these you find, you should
add an entry into tblImages. Then build a dynamic form - for each image
entry in tblImages, add another upload button as you did in step 1.
Then when an image is uploaded, flip the boolean field Fixed to true.
If Fixed is true, then don't display the upload form for that image.
<%
Set Conn = Server.CreateObject("ADODB.connection")
Set rst = Server.CreateObject("ADODB.Recordset")
Conn.Open "dsn=my_db;DATABASE=my_db"
strSQL = "SELECT * from tblImages WHERE Fixed = False AND DocumentID = " & ID
rst.Open strSQL, Conn
if not rst.eof then
do until rst.eof
%>
<form method="post" action="images.asp?ID=<% = ID %>" ENCTYPE="multipart/form-data">
<% = rst("FileName") %>
<input type="file" name="File">
<input type="Submit" value=" Upload " name="Submit">
</form>
<% rst.movenext
loop
<% end if %>
For example, if we detect three images in the document, you'll first
display three upload forms. When the user uploads the first image,
check the Fixed boolean entry, and add the name of the image file to
the database. The form will display again, but with only two upload
forms this time. Wash. Rinse. Repeat.
Of course, this will do you no good if the image source in the HTML
doesn't match the filename, so you'll have to go through the file one
more time and change/verify the sources.
|
NOTE:
When you upload images, note that the image name in the HTML source
might not match the actual image filename. For example, if you
insert an image called test1.gif into an MS Word Document and
export it to HTML, Word sometimes automatically changes the HTML
source to read image001.gif instead of test1.gif. Make sure that
you put the proper name into the database, and update the HTML
source to link to the correct image.
|
Step 3 - Layout
Content Management Made Easy with ASP
Administration
|