Gossamer Forum
Home : Products : DBMan : Customization :

adding photos to db

Quote Reply
adding photos to db
hi carol! welcome back! im still having trouble figuring out how to add photos to my database. i have read several of your responses to others asking the same question, but im still confused as how to go about this. here is what i want to do:

i have my script sitting on www.cantonconnection.com, however the script is called from www.pettys.com, which sits on a different server that does not, as yet, allow cgi scripts. this is why the script is running on the cantonconnection server. what i want to do, however, is to save the actual image files on the pettys server. what i would like to do is have a "camera" gif appear with each record that has a picture available with it. when the records are displayed, a viewer could click on the "camera" image, if the record has one, and a popup window would appear displaying the photo of the record.

how do i get the script to determine whether it should display the camera image for a link to a picture or not? and if i want to use a popup window instead of a new window entirely, can i do this without using java script? the last java script i tried to implement within the cgi script was not funtioning correctly. it was a script that would take the viewer to a confirmation page after a form submission, but the problem was that it was taking them to the page before the "mail sent" verification was actually done, resulting in no form data being sent even though the viewer was told that it was, so i had to remove it. anyway....if you could help me out with this picture thing, i would really appreciate it! thanx in advance....

chuck

------------------
pres@cantonconnection.com
Quote Reply
Re: adding photos to db In reply to
Pop-up windows have to be programmed via javascript since it is a client-side application. It is virtually impossible to create a server-side (i.e., cgi scripts, perl scripts, VBScripts, etc.) application to manipulate a client (i.e., web browser). Using javascript within cgi and perl scripts is not complicated. All you have to do is put the Javascript codes between the <head></head> anchors in sub-routines of perl files (like html.pl).

Are you inquiring about the File Upload Mod? It would be problematic to associate files uploaded on one server with their appropriate record number with a database on another server. The easiest thing to do would be to keep all the scripts on the same server.

If you have a set of photos located on another server that are not uploaded by users, then you could use virtual paths (with domain and directory) to these image files. However, that would dramatically slow download times. It is better to have all files located on one server.

Hope this helps.

Regards,



------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited September 22, 1999).]

[This message has been edited by Eliot (edited September 22, 1999).]

[This message has been edited by Eliot (edited September 22, 1999).]
Quote Reply
Re: adding photos to db In reply to
hi eliot! thanx for the response! yes i had the running between the head tags for the mail sent confirmation page, but it wouldnt run correctly for some reason. i use the same script on forms outside of the cgi script and it works fine, but for some reason trying to implement it with dbman is causing it not to work correctly. as for the other deal...the pictures...it isnt that big of a thing if i have to use a new window instead of a popup.

i read a post of carol's which was a response to someone asking a question similar to mine with regards to storing the image files on a server other than where the script was running. since then, however, i have not been able to find the post again! i guess i could save the images to the same server and just match the name of the image to the record name. but how do i get the script to recognize which record should have an image link displayed with it and which shouldn't?

thanx again....
chuck

------------------
pres@cantonconnection.com
Quote Reply
Re: adding photos to db In reply to
The file-upload mod, as it is set up requires all scripts and graphics to be on the same server. If your graphics are on a separate server from the DBMan script, you'll have to add a field to your database to hold the name of the file.

The problem comes from the fact that the mod checks the graphics directory to see if there's a graphic name to match the key for the record. But it can only read the directory on the current server. (If there's a way to read directories from a remote server, I don't know what it is.)

If every record had a graphic, there wouldn't be a problem, so long as the name of the graphic matched the key value for the record. Since every record does not have a graphic, though, the only way for DBMan to know when to try to display a graphic is for you to add a field to your database.

Does this help?

------------------
JPD





Quote Reply
Re: adding photos to db In reply to
hi carol! ok lets say i keep the image files on the same server as the script. i name the image for each record the same as the key field...which in this case is the stock number. so record 91219 would have an image file 91219.jpg. not all records will have an associated image though. so i add a field to the end of my display called "picture". if the record has an associated image, i would like a generic "camera" image to appear in this field....say "camera.jpg"...letting the viewer know there is a picture available for this record. the viewer could then click on the camera image and be taken to a page with the associated image file for that record. this field should be hidden if the record does not have an associated image. can this be done this way? would i also have to add a url field?

chuck

------------------
pres@cantonconnection.com
Quote Reply
Re: adding photos to db In reply to
If your graphic is on the same server as the script, you don't have to add a field. Are you using the file-upload mod? Or are you one who couldn't get it to work?



------------------
JPD





Quote Reply
Re: adding photos to db In reply to
no i havent heard of the file upload mod. where can i get it?


------------------
pres@cantonconnection.com
Quote Reply
Re: adding photos to db In reply to
ok carol....i think i just found the mod you are referring to, but if it's the correct one, it says i must be running on a unix system, which i am not....i'm running on an NT machine. is there some other way i can manipulate the script to do this?

chuck

------------------
pres@cantonconnection.com
Quote Reply
Re: adding photos to db In reply to
I don't know how to make it work on an NT system. It's just that I wanted to know what you were using so I wouldn't have to give you a whole lot of code for every possible scenario.

You will need to add a field to your database for the graphic. You can have the graphics on a separate server. If you name the graphic the same as the record key, you can just make the new field a checkbox.

I started to write the code for you and realized there might be another problem. Are all your graphics of the same type? All .gifs or .jpgs?


------------------
JPD





Quote Reply
Re: adding photos to db In reply to
It is highly problematic to do it on NT. Many NT users have experienced difficulties getting the File Upload mod to work.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: adding photos to db In reply to
hi carol....thanx for the response. im not sure what you mean by making the graphic field a checkbox field....unless you are referring to the add form. all of my image files will be jpg's.

chuck

------------------
pres@cantonconnection.com
Quote Reply
Re: adding photos to db In reply to
Yes, I'm thinking that you can just have a checkbox on the add form that says you have a graphic that goes with the record. That way you don't have to do as much typing when you're adding a record.

Add a field to your database:

Code:
Graphic => [9, 'alpha', 0, 3, 0, '', '']

Naturally, you would change 9 to the correct number for the field in your database. Be sure to add it at the end of your field list.

Add a checkbox field:

Code:
%db_checkbox_fields = ( Graphic => 'Yes' );

If you already have data in your .db file, you'll need to add an extra delimiter to the end of each existing record. If you don't have too many, just open the file in your text editor and add a | to the end of each line. If you have a large .db file, you might want to use Eliot's script. I'm sure he'll be willing to let you know where it is.

In your html.pl file, in sub html_record_form, add a line to print out the checkbox field:

Code:
<tr><td>Graphic:</td>
<td>&nbsp;|; print &build_checkbox_field("Graphic","$rec{'Graphic'}"); print qq|</td><tr>

In html_record, add

Code:
|;
if ($rec{'Graphic'} eq "Yes") {
print qq|
<a href="http://URL/to/graphics/directory/$rec{$db_key}.jpg" target="_new"><img
src="http://URL/to/camera/graphic/camera.gif"></a>|;
}
print qq|

That should make the camera graphic appear with the record when there's a graphic associated with the record and, if you click on the camera, you should get the graphic in a new window.

If you want to do a popup window or something fancy with Javascript, you'll need to get help from somebody else. I'm Javascript-challenged. Smile


------------------
JPD





Quote Reply
Re: adding photos to db In reply to
The Add Field script is in the Resource Center.

Smile

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: adding photos to db In reply to
ok carol i will try that! doesnt look to tough...i think i can handle it! thanx again, as always your help is greatly appreciated! thanx for the script location eliot! i only have about 35 records in there currently, but i think i'll grab the script for future use! thanx to both of you again!

chuck

------------------
pres@cantonconnection.com
Quote Reply
Re: adding photos to db In reply to
ok carol i made all of the changes you suggested, but i think i put the html.pl code for the sub_record in the wrong place. i placed it where i want the filed to show up and the script is kicking out an error when i try to run it. where exactly should the following code bo placed within my sub_record?

|;
if ($rec{'Graphic'} eq "Yes") {
print qq|
<a href="http://www.pettys.com/images/$rec{$db_key}.jpg" target="_new"><img
src="http://www.pettys.com/camera.jpg"></a>|;
}
print qq|

i currently have it looking like this:

sub html_record {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.

my (%rec) = @_; # Load any defaults to put in the VALUE field.
$rec{$db_key} =~ s/<?.B>//g;
1 while $rec{'Mileage'} =~ s/(\d)(\d{3})\b/$1,$2/;
1 while $rec{'Price'} =~ s/(\d)(\d{3})\b/$1,$2/;
$rec{'Price'} = "\$" . $rec{'Price'};
($db_auto_generate and print &build_html_record(%rec) and return);

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#820827';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';

print qq|
<HTML><BODY BACKGROUND="http://www.pettys.com/logofade2.jpg">
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#C9C9C9">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color><B>Stock:</B></FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Stock'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color><B>Make:</B></FONT></TD>
<TD> <$font>$rec{'Make'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color><B>Model:</B></FONT></TD>
<TD> <$font>$rec{'Model'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color><B>Year:</B> </FONT></TD>
<TD> <$font>$rec{'Year'}</A></Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color><B>Color:</B> </FONT></TD>
<TD> <$font>$rec{'Color'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color><B>Price:</B></FONT></TD>
<TD> <$font>$rec{'Price'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color><B>Mileage:</B></FONT></TD>
<TD> <$font>$rec{'Mileage'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color><B>Description:</B></FONT></TD>
<TD> <$font>$rec{'Description'}</Font></TD></TR>

</TABLE>
<a href="$db_script_link_url&more_info_form=1&$db_key=$rec{$db_key}">
Request more information</a>
|;
if ($rec{'Graphic'} eq "Yes") {
print qq|
<a href="http://www.pettys.com/images/$rec{$db_key}.jpg" target="_new"><img
src="http://www.pettys.com/camera.jpg"></a>|;
}
print qq|
</BODY></HTML>
}

thanx again!

chuck

------------------
pres@cantonconnection.com
Quote Reply
Re: adding photos to db In reply to
You need to add a

|;

after

</BODY></HTML>

That will stop your script from crashing. However, you probably shouldn't have </BODY></HTML> in sub html_record at all. That is taken care of within sub view_success.

If you take them out, take out the last print qq| as well, so that your sub html_record ends with

if ($rec{'Graphic'} eq "Yes") {
print qq|
<a href="http://www.pettys.com/images/$rec{$db_key}.jpg" target="_new"><img
src="http://www.pettys.com/camera.jpg"></a>|;
}


------------------
JPD





Quote Reply
Re: adding photos to db In reply to
thanx carol!!! it works great!

chuck

------------------
pres@cantonconnection.com
Quote Reply
Re: adding photos to db In reply to
I use this for displaying a photo near every record. It works fine, but there is only one problem.

Now I am using ID as dbkey. When $dbbold is set to 1, and the use do a LIST ALL, the picture isn't displayed, because db-man is searching after <b>1</b>.gif .

Is there a solution for this ?

My photo's are on another server.

------------------
--- Luc

[This message has been edited by LucVG (edited February 07, 2000).]
Quote Reply
Re: adding photos to db In reply to
LucVG,
This should help.

http://www.gossamer-threads.com/scripts/forum/resources/Forum12/HTML/000181.html

Strip <b> and </b> from url
Dave T
Quote Reply
Re: adding photos to db In reply to
Txs Dave,

works fine. No problem anymore. I think I must learn to use the search-option !



------------------
--- Luc