Gossamer Forum
Home : Products : DBMan : Customization :

Anyone into multiple uploads

Quote Reply
Anyone into multiple uploads
Hello All,
As its still the 90's and all is supposed to be possible I'd like to achieve multiple uploads!

But seriously I'd like to add more then one image to each record.

So when you add the upload mod to dbman the sub html_modify_form_record in html.pl specifys which directory to save the uploaded file to and assigns a name.

For example:
record=1 image=1.jpg
record=2 image=2.jpg

For multiple images I imagine the following:
record=1 image=1_a image=1_b image=1_c

So in the sub html_modify_form_record there is a hidden field naming the image:

<input type=hidden name="newfilename" value="$rec{$db_key}">

And this would be changed to;

<input type=hidden name="newfilename" value="$rec{$db_key}_a">

And if I wanted a maximum of 4 images I would have to have 4 upload fields in the modify form with each of them adding a different letter to the $db_key number. This could be acomplished by having 4 file-upload.cgi naming them file-upload1.cgi etc.

So my question is am I wasting my time or does this sound like a relatively simple modification.



------------------
Henk Jan Buchel
Classic Boatworld
http://classicboatworld.net
Quote Reply
Re: Anyone into multiple uploads In reply to
Hi,

Carol has helped me out with something like this a while back. I'll try to dig it up for you.

Eli
Quote Reply
Re: Anyone into multiple uploads In reply to
I would love to know how to do this too!!!

Greg
Quote Reply
Re: Anyone into multiple uploads In reply to
I am curious about this as well - I'll have to do the same thing.
Quote Reply
Re: Anyone into multiple uploads In reply to
Any thoughts on how to do this yet?

Quote Reply
Re: Anyone into multiple uploads In reply to
Here is what you do to if you want to upload 2 files at once.

In html_add_success, where you have the upload form,

change

Code:
<TR><TD ALIGN=RIGHT>File:</TD>
<TD><INPUT TYPE="FILE" NAME="file-to-upload-01"
SIZE="35"></TD></TR>

to

Code:
<TR><TD ALIGN=RIGHT>Full-size image:</TD>
<TD><INPUT TYPE="FILE" NAME="file-to-upload-01"
SIZE="35"></TD></TR>
<TR><TD ALIGN=RIGHT>Thumbnail image:</TD>
<TD><INPUT TYPE="FILE" NAME="file-to-upload-02"
SIZE="35"></TD></TR>


Make the same change in html_modify_form_record.

In the file-upload.cgi script,

Change

Code:
$Filename = param('newfilename') . lc(substr($Filename,-
$extension_length,$extension_length));

To


Code:
if ($Number == 1) {
$Filename = param('newfilename') . lc(substr($Filename,-
$extension_length,$extension_length));
}
else {
$Filename = param('newfilename') . "_2" . lc(substr($Filename,-
$extension_length,$extension_length));
}


(There should only be one line between "if" and "}" -- and between
"else" and "}".

Whenever you want to use the small image, use


Code:
|; # to close off a previous print qq| statement
$ALLOWED_EXT =~ s/\\.//g;
$ALLOWED_EXT =~ s/\$//g;
@extensions = split (/\Q|\E/o,$ALLOWED_EXT);
GRAPHIC: foreach $extension (@extensions) {
if (-e "$SAVE_DIRECTORY/$rec{$db_key}_2.$extension") {
print qq|<img src=
"$SAVE_DIRECTORY_URL/$rec{$db_key}_2.$extension">|;
last GRAPHIC;
}
}
print qq|


#When you want to use the large image use

Code:
|; # to close off a previous print qq| statement
$ALLOWED_EXT =~ s/\\.//g;
$ALLOWED_EXT =~ s/\$//g;
@extensions = split (/\Q|\E/o,$ALLOWED_EXT);
GRAPHIC: foreach $extension (@extensions) {
if (-e "$SAVE_DIRECTORY/$rec{$db_key}.$extension") {
print qq|<img src=
"$SAVE_DIRECTORY_URL/$rec{$db_key}.$extension">|;
last GRAPHIC;
}
}
print qq|

(This last one is the same as is in the original script.)

This should do the trick. Let me know if it works for you.

Thanks
Eli
Quote Reply
Re: Anyone into multiple uploads In reply to
Thanks Jfrost,

Looks interesting and less complicated then the way I was going about it.

I see that the code is set up so that users can include a thumnail.

I am building a new dbman in wich I want to allow users to upload 3 different images. So I have to think about the thumnail option because then I would require users to make 6 uploads which might be to much.

Am I correct in assuming that if I wanted to upload 3 images that the file upload.cgi would then be;

if ($Number == 1) {$Filename = param('newfilename') . lc(substr($Filename,-$extension_length,$extension_length));
}
else {$Filename = param('newfilename') . "_2" . lc(substr($Filename,-$extension_length,$extension_length));
}
else {$Filename = param('newfilename') . "_3" . lc(substr($Filename,-$extension_length,$extension_length));
}

Regards,
HJ



------------------
Henk Jan Buchel
Classic Boatworld
classicboatworld.net

[This message has been edited by HJ (edited December 01, 1999).]
Quote Reply
Re: Anyone into multiple uploads In reply to
I implemented this mod to the original file upload mod and noticed three things that perhaps others have already figured out:

1) at least in my distribution of the mod, there is no line...
Code:
$Filename = param('newfilename') . lc(substr($Filename,-$extension_length,$extension_length));
I assume you mean/meant/could substitute...
Code:
$Filename = $newfilename . lc(substr($Filename,-$extension_length,$extension_length));

2) only one file can get uploaded at a time (always the thumbnail), even if paths to both images are specified.

3) to get both images uploaded, the thumbnail must be uploaded first, then the full size image can be uploaded by modifying the record. If one attempts to upload the full size image first, then the thumbnail, the full size image is deleted during the thumbnail upload process.

Help on a fix to these probs?