Gossamer Forum
Home : Products : DBMan : Customization :

Upload Mod Question

Quote Reply
Upload Mod Question
I've read through the entire forum for help on this problem and gave up. I've installed the new upload mod in my application and even installed it into a clean version of dbman. Here is the problem:

From the add new record form I can select and upload image files. I've checked the upload directory and they do indeed show up fine. On the confirmation screen, "add record successful", the record is blank. Also when I check the database, the record was not written. I've backed out of the mod a few times and everything works ok. Anyone run into this? I've checked and rechecked the changes and I'm convinced that I've done everything to the letter. Does anyone here have a clue to what might be causing this?

Quote Reply
Re: Upload Mod Question In reply to
This may not be much help, but I had a similar problem a few weeks back.
My post is at:
http://www.gossamer-threads.com/...w=collapsed&sb=5
I mod my DBman offline on win 95, but my server is Unix. What I found is that the upload mod has a problem uploading gif files on windows, jpegs are fine. It uploads gifs as 0 byte files.
So you may have the same problem if your on an NT server. I didn't bother about it much, because gifs upload fine on my unix server, although I did include some error checking for other types of files that also upload as 0 byte files. If your using NT, try a jpeg.

Bob
http://totallyfreeads.com

Quote Reply
Re: Upload Mod Question In reply to
Thanks for the reply. I'm uploading to Apache and they seem to work fine. The directory is created with the record number as it should and the files I selected are uploaded correctly. The contents of the record that I submit is not, however, written to the database but a carriage return is - which is why a get a blank record on the confirmation screen of add new record.

Another slight twist is that when I list all - and I know that there is one valid record in the database - I get an error message: "no search terms specified". The list all uses a "*" wildcard to list all records. If I do a modify, go the search screen and enter a "*" for the ID, I get an "illegal division by zero" in the html.pl script and the same thing if I try to do a delete.



Quote Reply
Re: Upload Mod Question In reply to
Thanks to someone on this list, the problem was solved - well sort of. The solution it appears is that with this mod the database has to be within the scope of the webserver root to work correctly. Normally, I store all database files, password files, etc., outside the webserver root to avoid exposing these files to hackers. So, one more question: why does this mod force me to move my database? Does everyone do that???

Quote Reply
Re: Upload Mod Question In reply to
It doesn't have to be in the webserver root. It has to be in your cgi-bin.

I don't have root access on my server and the upload mod works just fine.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Upload Mod Question In reply to
But i do believe you graphics may have to be stored out of the cgi-bin on some servers to display.

Or at least I've heard of some people having problems if they've done so, I can store graphics in the cgi-bin with my host provider.

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Upload Mod Question In reply to
Yes, that is correct. That's why I added the notation in the mod that the upload directory should not be in the cgi-bin. If you know that your server allows it, that's fine, but putting it in the public directory will work for everyone.


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Upload Mod Question In reply to
This a likely a semantic problem. The webserver root is the point within a directory structure and below that is visible and exposed to the webserver. Logging in as root, gives you access to not only where the webserver directory structure begins but also everything above. For instance, if the directory structure on the PC that runs your server is like this:

var/www/mysite/

and your domain name server points to mysite, the webserver root begins at the mysite directory level. Everything from mysite and below is exposed and accessible to a web browser. Logging in as root, gives you access to everything above "mysite" and below it.

For security reasons, you don't normally store databases within the scope of a webserver. That is, access to a database would be at:

var/www/databases

Since the webserver root begins at
var/www/mysite and the only access available to var/www/databases is through a script, hackers normally can't get above the webserver root unless they have figured out how to login as root (logging in as root gives access from the webserver root and above).

This mod (and a very nice one it is) forces the dbman database (not the image database) to be stored within the webserver root (the cgi-bin directory is within the webserver root).

I have and maintain several dbman databases, all of which are currently stored outside the scope of the webserver root accept for this one.

Maybe I'm not explaining this well enough. I'm not in anyway complaining, just trying understand why it's necessary.

Regards,
Phil







Quote Reply
Re: Upload Mod Question In reply to
I'm not sure it is necessary, but then I've never worked with a Windows system. What I'm used to is a Unix system whereby no one can access (directly) the files that are in my cgi-bin.

Do you have any idea which code it is that's causing the problem? I would have no idea where to even start looking.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Upload Mod Question In reply to
I'm banging my head on this as well. However, I'm seeing this on my NT server that I'm using this upload MOD on. Here's what I have...

Submit record and attach file. It gets uploaded to the server and the record is added. However, seemingly randomly, the record doesn't show up when I'm doing a view all. But if you do a search selection where you know that the affected record will show up, it does. (Such as a search for modify or delete).

This is getting frustrating because the record is in the Database and the file is on the server. But the routine that decides what to show: (in my case)

Code:
opendir (GRAPHIC, "$SAVE_DIRECTORY") or
&cgierr("unable to open directory in doc files: $SAVE_DIRECTORY. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
$file_test = $rec{$db_key};

foreach $file (@files) {
if ($file =~ /^$file_test\./) {

$urlfile = &urlencode($file);

$extlength = length($file) - index($file,".");
$ext = substr($file,-$extlength,$extlength);

if ($ext eq ".pdf") {$imagetype = "small-pdf.gif"}

elsif ($ext eq ".xls") {$imagetype = "small-xls.gif"}
elsif ($ext eq ".htm") {$imagetype = "small-netscape.gif"}
elsif ($ext eq ".html") {$imagetype = "small-netscape.gif"}
elsif ($ext eq ".doc") {$imagetype = "small-word.gif"}
elsif ($ext eq ".mdb") {$imagetype = "small-mdb.gif"}

else {$imagetype = "small-blank.gif"}


print qq|
<p><img src="/images/icons/$imagetype" width="16" height="16" align="baseline"
border="0"> <a href="$SAVE_DIRECTORY_URL/$urlfile" target="_top">$rec{'title'}</a> - <em><small>(updated
$rec{'date'})</small>

<small> </small></em>$rec{'functional_area'}
- $rec{'author'}</p>|;

$graphic_found=1;
}
}
Skips some of my records.

Any ideas?

Quote Reply
Re: Upload Mod Question In reply to
Are you sure you have the line

$rec{$db_key} =~ s/<.?B>//g;

right after

my (%rec) = @_;

in sub html_record?

Your comment

However, seemingly randomly, the record doesn't show up when I'm doing a view all. But if you do a search selection where you know that the affected record will show up, it does.

seems to suggest that you don't have the line that takes out the bolding tags.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Upload Mod Question In reply to
JPD,

Yes, I do have that item in the code. I also turn off bolding for the search results as well. As I mentioned in a previous post, the script actually recognizes that there is a record to display (because if you modify or delete an item, the script places the radio button or checkbox beside the record), but it doesn't display the output from &html_record.

Of course, now I'm having to dig in and see why when a user uploads a new record, or modifies an old record and uploads a file, other uploaded files are deleted. Grrr...

Thanks for taking a look...

-Dave

Quote Reply
Re: Upload Mod Question In reply to
Dave, is it possible for me to see your database in action? I'm having a hard time picturing the problem.

JPD
http://www.jpdeni.com/dbman/