Gossamer Forum
Home : Products : DBMan : Customization :

upload mod -- is this a bug?

Quote Reply
upload mod -- is this a bug?
Hi! It's me again Smile

I've searched the FAQ for "images" and related terms, and the forum for this error. Maybe I've missed something?
I am using multiple file upload mod 3. Everything is fine, BUT:

1.) When I am choosing a file for upload with an extension that is not allowed (e.g., xls), then I get the usual Error message from sub html_add_failure. Let's say the ID of this record is 124
2.) Despite this error message, dbman has already created an (empty) directory named 124 that is aimed for the file upload.
3.) When I fix the problem and choose a correct file and hit the Add-button again, I am getting a CGI ERROR:
CGI ERROR
==========================================
Error Message : unable to open directory. Reason: No such file or directory

I have tried around and realised that the problem must be cause by the fact that the directory 124 had been created before!

Below is the related code in the sub html_record_form.
Any ideas?
TANK YOU IN ADVANCE

|;
if ($form_upload_add) {
print qq|<tr><td colspan=2>You may upload up to $MAXIMUM_FILES files, for a total of
$MAXIMUM_UPLOAD bytes.</td></tr>|;
for ($u=1;$u<=$MAXIMUM_FILES ;++$u) {
print qq|
<TR><TD>Browse Picture:</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..
++$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>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;
print qq|<tr><td colspan=2>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.</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="50"></TD></TR>|;
}
}
print qq|

Last edited by:

Muhe: Apr 21, 2008, 4:56 AM
Quote Reply
Re: [Muhe] upload mod -- PROBLEM SOLVED In reply to
How crazy can one be???

The solution is this thread:
http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=246706;search_string=upload%20mod;#246706

I had seen and read this thread several times, but I never found these two quotes missing in my own script. Crazy
Quote Reply
Re: [Muhe] upload mod -- PROBLEM SOLVED In reply to
i think the bad line without quotes is in the cgi file, not the html.pl file.