Gossamer Forum
Home : Products : DBMan : Customization :

(single) file upload, uploaded files are deleted

Quote Reply
(single) file upload, uploaded files are deleted
After spending many hours in trying to install the mod file upload succesfully still serious problems are there, so its time to ask this forum for a helping hand.

---installing the (single) file upload mod---

The .cgi can be called without problems, when I logged in, and go to the form to add (toevoegen) a record, it displays correctly. It is no problem to load up an image from my harddisk. When I hit the submit (toevoegen) button strange things happen:

The first added record don't have a ID-number (the counter is set to 1 at startup).
The second added record gets number 1, the third numer 2 and so on.
No images show up after succesfull adding because after adding the first record the 'index' and 'index.cache' files (which already are in the folder 'uploads' chmod set to 777) are deleted , the first image shows up as .jpg, the second image as 1.jpg the third as 2.jpg etc.
After fixing the erased files 'index' and 'index.cache' by adding them again, the images now show up when adding another record or when a record is called for modification.
When modifying (wijzigen) a record, new problems are there. The added record cannot be found or multiple images show up.
When I'am logging in with a different username and add a record, all previous uploads are deleted as well the 'index' and 'index.cache' files.

Because in my .db file the path of the uploaded image is like d:/myimages/caravan1.jpg I looked around in this forum and read about possible server-problems. Because of that
I had made a fix to the .cgi file by changing a selection of section sub validate_upload

# fix as named in threat 13 mar 01 (Graphic upload problem)
# $file_test = $in{$db_key} . ".";
$file_test = $rec{$db_key};

No succes after this fix.

Also tested changing the $db_script_path
$db_script_path = "/home/users/my/server/www/db"; #full
$db_script_path = "."; #short

short or full path, it make no difference, so set it again short (standard)

For troubleshooting I have placed the .cgf .pl .cgi as txt-files on my server.

http://www.caravans.nl/db/doc.cfg.txt
http://www.caravans.nl/db/doc.pl.txt
http://www.caravans.nl/db/doc.cgi.txt

Please help me out with this one.

Joost

Quote Reply
Re: (single) file upload, uploaded files are deleted In reply to
Hello Joost, it would appear you have properly installed the mod - I was not able to find anything out of order there. I did however find a couple of things to ask you about. In your database configuration file, you have the following two fields listed:

'UserID' => [0, 'numer', 5, 8, 0, '', '' ],
'ItemID' => [1, 'numer', 5, 8, 0, '', '' ],

Are your UserID's actually numerical? Usually the UserID is a lower case name or something. Perhaps try changing the field definition as indicated:

'UserID' => [0, 'alpha', 5, 8, 0, '', '' ],
'ItemID' => [1, 'numer', 5, 8, 0, '', '' ],

In sub html_record_form you have the following listed:

<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color></FONT></TD>
<TD VALIGN="TOP" WIDTH="350"> <INPUT TYPE="TEXT" NAME="ID" VALUE="$rec{'ItemID'}" SIZE="5" MAXLENGTH="8"><$font_color></TD></TR>

I am going to guess that because you do not have any text displayed in the row with this data field, you want that ItemID to automatically be entered by the scripts (that's what you have configured in your doc.cfg file anyway Smile). Try changing that row so the top part of your form looks like this:

sub html_record_form {
# --------------------------------------------------------

my (%rec) = @_;
($db_auto_generate and print &build_html_record_form(%rec) and return);

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#6B6B47';
print qq|
<INPUT TYPE="hidden" NAME="UserID" VALUE="$rec{'UserID'}">
<INPUT TYPE="hidden" NAME="ItemID" VALUE="$rec{'ItemID'}">

<TABLE WIDTH="600" CELLPADDING=0 CELLSPACING=0 BORDER=0 BGCOLOR="#F3F3E7">
<TR><TD ALIGN="Right"><$font_color> </FONT></TD>
<TD> <$font_color><i>Kies het soort kampeermiddel.</i></FONT></TD></TR>


Notice there ... you will have properly gotten the ItemID so the script knows which record it is working with and you have picked up the UserID so the script knows who the record belongs to.

Good luck - Let us know if you have other problems.

Quote Reply
Re: (single) file upload, uploaded files are deleted In reply to
Thanks Karen for this quick responding.

Changing the .cfg file
----------------------
The UserID is indeed a lowercase name, I have changed this field to a 'alpha' field. After adding records the fieldnumbers are oke now. Also the problem of not recognizing previous added records for modifying is now fixed. To optimize the configuration I have changed the position of the UserID and ItemID. ItemID is now at position '0' and UserID at position '1'. The $auth_user_field is also set to the correct position ('1'). These settings works fine.

Changing the .pl file
---------------------
Your guess was right, I want the script to automatically enter the ItemID to the database. As by your suggestion I set the top part of the form (sub html_record_form) like this:

<INPUT TYPE="hidden" NAME="ItemID" VALUE="$rec{'ItemID'}" SIZE="5" MAXLENGTH="8">
<INPUT TYPE="hidden" NAME="UserID" VALUE="$rec{'UserID'}" SIZE="5" MAXLENGTH="8">

The screenoutput is oke, ItemID and UserID are correctly added to the database. This settings works fine.


Deleting file problem is still there
-------------------------------------
After the modification as described above still the problem of deleting files is there.
When adding a new record which includes an uploaded image all previous files (not only the uploaded images but also the 'index' and 'index.cache'files) are deleted in the folder 'uploads' on the server. After adding multiple records only the latest added imagefile is in the folder uploads.

When I take a look to added records in the .db file at the position of the imagefile a path like this is given: D:\uploads\caravan1.jpg
In the folder uploads this file is named 1.jpg

May there be a need to add/change something to the files
index (content: attributes=serveall)
index.cache (content: serveall=true)
These files are needed in the folder uploads, because without these files it is not possible to call/view (image)files in a webbrowser.

sub html_record_long
--------------------
Installing the mod 'file upload' the next part must be added to the sub html_record_long in the .pl file:

|; # to close off a previous print qq| statement
opendir (GRAPHIC, "$SAVE_DIRECTORY") or &cgierr("unable to open directory in delete records: $SAVE_DIRECTORY. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
$file_test = $rec{$db_key} . ".";
foreach $file (@files) {
if ($file =~ /^$file_test/) {
print qq|<img src= "$SAVE_DIRECTORY_URL/$file">|;
$graphic_found=1;
}
}
print qq|



Question:
Is it of any use to change:

$file_test = $rec{$db_key} . ".";

in:

$file_test = $rec{$db_key};

This because this fix is named in threat 13 mar 01 (Graphic upload problem) in relation to the need to modify the .cgi file (in section: sub validate_upload)

All changes named in this reply are added to the .cfg .pl .cgi files which as .txt files can be viewed for trouble shooting. The links are in the startmessage of this threat.

Joost




Quote Reply
Re: (single) file upload, uploaded files are deleted In reply to
Hello Joost, I believe that the 'deleting other files' problem you are experiencing may be due to having entries in your database that do not have an ItemID associated with them. The file upload mod should only be identifying files associated with a particular record for adding/removing files. You had entries being added without an ItemID or UserID associated with them.

If you do not have many records in your database, your best (easiest) option may be to just upload a fresh, empty database file to your system and start from there.

As for the renamining on the images - yes, the program will rename the image file to correspond to your record (ItemID) number. Regardless of what the file is named on your local system, the file will be renamed to be the same as the ItemID number.

Quote Reply
Re: (single) file upload, uploaded files are deleted In reply to
Karen,

In previous testing already an empty database was used as well as a reset of the counter. I tried it again serveral times but still the deleting file problem is there.

As it seems the mod is correctly installed I now have send email of this problem to my hostingprovider for analysing this issue; is this a serverproblem?

As soon I receive a reply from my serveprovider whitch will make this mod work succesfully, I will post this outcome in this thread.

Hopefully it will work once....

Joost