Gossamer Forum
Home : Products : DBMan : Customization :

Another File Upload Opportunity

Quote Reply
Another File Upload Opportunity
Hi again!

I've installed JPD's Multiple File Upload Mod to pull up to five graphic files into the the html_record_long display.

Can anyone give me a pointer on how to display the graphic files at different positions within the record ie. first graphic at the beginning of the record, second graphic after displaying a few fields, etc.?

Will I have to create separate fields for each graphic? or can I handle the graphic files directly - the idea is to name the graphic files with the record number and a letter ie. record number 1020 has graphic files 1020a.jpg, 1020b.jpg, etc.

Any help would be greatly appreciated!

Keef

Quote Reply
Re: Another File Upload Opportunity In reply to
I tried to do that once, but I couldn't get it to work.

The only way I can figure to do this would be to put the graphic file names into an array in sub html_record (or sub html_record_long). Then you could print out different ones in different places. They would probably be in alphabetical order by the original names of the files, so the users would have to name their files differently if they wanted them in different order.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Another File Upload Opportunity In reply to
JP, thanks for the advice . . . and it works!

Just to be complete and for those who come after, here is the code I used/modified:

# put the photos into an array called @photo
if (-e "$SAVE_DIRECTORY/$rec{$db_key}") {
opendir (GRAPHIC, "$SAVE_DIRECTORY/$rec{$db_key}") or &cgierr("unable to open directory: $SAVE_DIRECTORY/$rec{$db_key}. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
@photo = qw();
foreach $file (@files) {
next if ($file =~ /^\./); # Skip "." and ".." entries..
next if ($file =~ /^index/); # Skip index.htm type files..
push(@photo, $file);
}
}

# then to print out individual photos on the page
print qq|<img src= "$SAVE_DIRECTORY_URL/$rec{$db_key}/$photo[0]">|;

# above would print photo 0 in the array
# repeat the print line where you need to to print the other photos for photo 1, 2, 3, etc.

Keef


Quote Reply
Re: Another File Upload Opportunity In reply to
Excellent!! Smile


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Another File Upload Opportunity In reply to
hi , i do follow keef modified,there are something unusual,
I want only the first uploaded image to be placed on the long page,but the code below i modified bring up 5 images of the FIRST uploaded-image.(it is 5 images coz i uploaded total 5 images IF total file is 1 it will show 1)


my $img_cols = 5;

if (-e "$SAVE_DIRECTORY/$rec{$db_key}/tn") {
opendir (GRAPHIC, "$SAVE_DIRECTORY/$rec{$db_key}/tn") or &cgierr("unable to open directory: $SAVE_DIRECTORY/$rec{$db_key}. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
@photo = qw(); #add this for photo
my $col_count = 0;
print '<table border="0"cellspacing="0" cellpadding="4">';
foreach $file (@files) {
next if ($file =~ /^\./); # Skip "." and ".." entries..
next if ($file =~ /^index/); # Skip index.htm type files..
push(@photo, $file); #add this for photo
print '<tr>' if ($col_count eq 0);
print qq|<td>
<div align="center"><img src="$SAVE_DIRECTORY_URL/$rec{$db_key}/$photo[0]"></div>
<table border="0" bgcolor="#EEEEEE" cellspacing="0" cellpadding="4">
<tr><td><a href="$SAVE_DIRECTORY_URL/$rec{$db_key}/$file"target=_blank><img src="$SAVE_DIRECTORY_URL/$rec{$db_key}/tn/$file" border="0"></a></td></tr></table></td>|;
$col_count++;
if ($col_count eq $img_cols) {
print '</tr>';
$col_count = 0;
}
}

# Insert blank cells if row finishes early.
if ($col_count ne 0) {
for ($i = $col_count; $i <= $img_cols; $i++) {
print '<td> </td>';
}
}

print '</table>';
}


Regards,
Act.
I am new to cgi, Thank you for your help.
Quote Reply
Re: Another File Upload Opportunity In reply to
HI, has anyone got a solution for this case,
I want the 1st uploaded file to be place in original size.
and all uploaded be in thumbnail size.
see the code above ,and tell me what should i do.
Any help would be great.

Regards,
Act.
I am new to cgi, Thank you for your help.
Quote Reply
Re: Another File Upload Opportunity In reply to
Hello act, it looks as though you have two different mod attempts going and one is not compatible with the other.

Code:
my $img_cols = 5;

if (-e "$SAVE_DIRECTORY/$rec{$db_key}/tn") {
opendir (GRAPHIC, "$SAVE_DIRECTORY/$rec{$db_key}/tn") or &cgierr("unable to open directory: $SAVE_DIRECTORY/$rec{$db_key}. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
@photo = qw(); #add this for photo
my $col_count = 0;
You cannot have the scripts automatically assigning images into columns and also have the control over where the image displays which is what Keef's instructions are doing.

You'll need to go back and take out all of the modifications you made for the column display, then come back to Keef's instructions for placing images in particular locations.

Quote Reply
Re: Another File Upload Opportunity In reply to
oK, my need fixed,
I just put this code above my old code
,so there are 2 table of images,one table i can choose where to place which image and other is table column of all images.
:))
Thank you.


Please Excuse me for my poor knoledge of PERL
Regards,
Act.