Gossamer Forum
Home : Products : DBMan : Customization :

Image fields/images on add failure

Quote Reply
Image fields/images on add failure
When I reach my add failure page, my image fields are blank even though I added the images on the add form and I know that they are recorded because it wont let me add new ones without saying that you have exceeded your limit, so how do I get the image file names to still appear in the fields or have the images themselves show up in the add failure so users do not think they need to re-add them?

Thanks!
Quote Reply
Re: [wdu2002] Image fields/images on add failure In reply to
Can anyone answer this for me please? I am assuming that I can put something in this code thats in the html_record_form sub?? since the add_failure sub only refers to the html_record_form sub anyway. But Im not positive on that or where or what to put. Can anyone help? TIA!

Code:
if ($form_upload_mod) {
if (-e "$SAVE_DIRECTORY/$rec{$db_key}") {
@files = &_readdir($rec{$db_key});
@photo = qw ();
foreach $file (@files) {
next if ($file =~ /^\./); # Skip "." and ".." entries..
next if ($file =~ /^index/); # Skip index.htm type files..
push (@photo, $file);
++$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..
print qq|<tr><td><$font>Delete file
<input type="checkbox" name="$file" value="delete"></td>
<td><img src="$SAVE_DIRECTORY_URL/$rec{$db_key}/$file"></td></tr>|;
}
}
$new_files=$MAXIMUM_FILES - $num_files;
$new_bytes=$MAXIMUM_UPLOAD - $prev_bytes;
for ($u=1;$u<=$new_files ;++$u) {
print qq|<TR><TD colspan=2><$font>You currently have $num_files files associated with this record, for a total of $prev_bytes bytes. You may upload up to $new_files additional files, with a total byte size of $new_bytes bytes.</font></TD></TR>
<TR><TD><$font>Photo:</font></TD><TD><INPUT TYPE="FILE" name="file-to-upload-$u" SIZE="30"></TD></TR> |;
}
Quote Reply
Re: [wdu2002] Image fields/images on add failure In reply to
quoted from thread "Understanding File Upload"

With the upload mod, the filename is changed to match the value of the $db_key field for the record. That means that the file will be saved as 1.jpg in your upload directory. (It doesn't matter a hill o' beans what the original location or name of the file was.)

When the file is displayed, the script goes by the key value of the record to find any file that has the same name + an extension.

==========

Therefore the add failure page can't list your filenames as they are not held within the database.

If you mark each required field as such then they will know which fields have to be filled out to prevent an add failure.

You could also include an explaination as to how the image fields work on the top of your add_form, or within a FAQ for using the database so people will know what to expect when adding or modifying records.

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/
Quote Reply
Re: [LoisC] Image fields/images on add failure In reply to
Thank you Lois. I had already been through the file upload mod procedures when I added this feature, so I didnt think it would be included in that. I just didnt want users who might have made a mistake with forgetting to add something have problems with their images if they think that they have to readd them since they arent listed, but I guess i'll just have to add some sort of statement so they know. Thanks for replying!