Gossamer Forum
Home : Products : DBMan : Customization :

AstroBoy,please help

Quote Reply
AstroBoy,please help
Hi,AstroBoy
I looking for someone to fix this modify for me for long time,so i need you help coz someone told me asking you.
I add multiple-images-upload mod to my db,but now i want the images to be placed in colum display format like 4x4...5x5
,but i dont know how to.
below is code i cut from .html
=====================
### Wherever you want your graphics to print out, use the following:

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);
foreach $file (@files) {
next if ($file =~ /^\./); # Skip "." and ".." entries..
next if ($file =~ /^index/); # Skip index.htm type files..
print qq|<td valign="middle" align="center"><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>
|;
}
}

what should i do with it,thanks
ps. i am not a cgi literated so please help me write down the modify,and i will try it if success.

Regards,
Act.
I am new to cgi, Thank you for your help.
Quote Reply
Re: AstroBoy,please help In reply to
Hi act,

Taking the code you posted, I've come up with the following.
Copy the code, and paste it wherever you want the table of images to appear.

It works almost identically to the old code.
All you need to do is define the number of columns you wish to have.
That particular area is highlighted in red.

Code:
####################################################################
### Wherever you want your graphics to print out, use the following:

# Set the following to the number of colums you want to display:
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);

my $col_count = 0;
print '<table border="0" bgcolor="#EEEEEE" cellspacing="0" cellpadding="4">';
foreach $file (@files) {
next if ($file =~ /^\./); # Skip "." and ".." entries..
next if ($file =~ /^index/); # Skip index.htm type files..
print '<tr>' if ($col_count eq 0);
print qq|<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>|;
$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>&nbsp;</td>';
}
}

print '</table>';
}

####################################################################
I'm not familar at all with the upload mod, so I can't guarantee the above code will work as expected.

I hope it at least gets you started on the right track.

Regards,

- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: AstroBoy,please help In reply to
Hi, :)
It works!!
You know ,I awaitting some1 to do modify this for me for long time.Thank you very much and also thank LoisC who told me asking YOU :) :) :)

Then how to allow user to upload just xx images at once a time, i mean such as if we allow user upload 10 images but force him to upload 5 images a time not 10,to prevent long upload times. then if the first 5 images uploaded ,if user click to modify again he will get the next 5 images or the left to be uploaded........I dont know if you want another file to modify or not but below I cut from .html file
in sub html_record_form
Code:

if ($form_upload_add) {
print qq|<tr><td colspan=2><$font>
<ul>
<li>
images allowed $MAXIMUM_FILES images (
$MAXIMUM_UPLOAD bytes)
</ul>
</font></td></tr>|;
for ($u=1;$u<=$MAXIMUM_FILES ;++$u) {
print qq|
<TR><TD><$font><b>Picture</b></font></TD>
<TD><INPUT TYPE="FILE" NAME="file-to-upload-$u" SIZE="50"></TD></TR>|;
}
}
if ($form_upload_mod) {
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);
foreach $file (@files) {
next if ($file =~ /^\./); # Skip "." and ".." entries..
next if ($file =~ /^index/); # Skip index.htm type files..
next if ($file =~ /^tn$/); # Skip TN directory..
++$num_files;
@stats = stat "$SAVE_DIRECTORY/$rec{$db_key}/$file";
$prev_bytes +=$stats[7];
}
foreach $file (@files) {
next if ($file =~ /^\./); # Skip "." and ".." entries..
next if ($file =~ /^index/); # Skip index.htm type files..
next if ($file =~ /^tn$/); # Skip TN directory..
print qq|<tr><td>Delete file
<input type="checkbox" name="$file" value="delete"></td>
<td><img src= "$SAVE_DIRECTORY_URL/$rec{$db_key}/tn/$file" border="0"></td></tr>|;
}
}
$new_files=$MAXIMUM_FILES - $num_files;
$new_bytes=$MAXIMUM_UPLOAD - $prev_bytes;
print qq|<tr><td colspan=2><$font>uploaded: $num_files ΓΩ» ($prev_bytes bytes). more $new_files pic ($new_bytes bytes) can be uploaded.

<$error_color></font></font></td></tr>|;
for ($u=1;$u<=$new_files ;++$u) {
print qq|
<TR><TD>Browse Picture:</TD>
<TD><INPUT TYPE="FILE" NAME="file-to-upload-$u" SIZE="40"></TD></TR>|;
}
}




Regards,
Act.
I am new to cgi, Thank you for your help.
Quote Reply
Re: AstroBoy,please help In reply to
Hi,Happy Chinese Newyear!


Regards,
Act.
I am new to cgi, Thank you for your help.
Quote Reply
Re: AstroBoy,please help In reply to
AstroBoy Are you around?or if any1 can fix this.

Regards,
Act.
I am new to cgi, Thank you for your help.
Quote Reply
Post deleted by act In reply to
Quote Reply
Re: AstroBoy,please help In reply to
Hi,
I want to allow user upload iamge just X images a time,not $MAXIMUM_FILES a time.
how to modify the code below;


|;
for ($u=1;$u<=$new_files ;++$u) {
print qq|
<TR><TD>Browse Picture:</TD>
<TD><INPUT TYPE="FILE" NAME="file-to-upload-$u" SIZE="40"></TD></TR>|;
}
}
print qq|


Please Excuse me for my poor knoledge of PERL
Regards,
Act.
Quote Reply
Re: AstroBoy,please help In reply to
Hi, Mark ,if you around, I really need your help.
Thank for your attention :)


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