Gossamer Forum
Home : Products : DBMan : Customization :

File name length limitation

Quote Reply
File name length limitation
Is there a character limit on the length of an uploaded file name?

I'm finding that files with long names appear to be truncated when they are uploaded. Is this a function of DBMAN or a server limitation?

John
Quote Reply
Re: [jgold723] File name length limitation In reply to
Probably not a server limitation unless you're running on really old Netware or DOS. Are there spaces in the file names? That can cause problems on Unix. Unix is also case sensitve.

How are the names being truncated? Could be some weird characters that perhaps the script is converting?
Quote Reply
Re: [Watts] File name length limitation In reply to
There are spaces -- although this doesn't seem to be a problem with the shorter file names.

There also seems to be an odd character (a O with an umlaut over it) that doesn't appear in the linked text, but can be seen in the actual URL -- it appears to be a translation of the .... that DBMAN creates when it truncates the name.

And -- stranger still -- all of the links seem to work fine when viewing the site with IE 5.0 on the Mac. However, windows machines give a "URL not found" error when you click on the broken links.

If you want an example, follow this link:

http://www.sacomaine.org/cgi-bin/councildb/db.cgi?db=default&uid=default&view_records=1&ID=*&nh=29&mh=1

Links to the files are at the bottom of the page. The very first item is an example of the broken link.

John
Quote Reply
Re: [jgold723] File name length limitation In reply to
Try this:

Linking to fields with spaces

If the only problem you're running into is spaces, you can use:

$rec{'FieldName'} =~ s/ /+/g;

For each field that might have spaces in it. If you are going to have other characters that might cause problems,
there's another subroutine that will do the conversion.

Add the following somewhere in db.cgi -- anywhere is fine, as long as it's not in the middle of another subroutine.

sub urlencode {
# --------------------------------------------------------
my($toencode) = @_;
$toencode=~s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
$toencode=~s/\%2F/\//g;
return $toencode;
}

Then, before you print out your link in html.pl, use:

$rec{'FieldName'} = &urlencode($rec{'FieldName'});


If that doesn't help check the FAQ noted below under Linking or images .. i'm sure this problem has been addresses and hopefully the solution is posted.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] File name length limitation In reply to
Hi Lois:

Thank you for this - it looks great.

However, I'm having this problem with the multiple upload mod, which, it appears, creates the url based on the name of the uploaded file.

Somehow files with very long names have the name altered during the upload process.

Would this cleanup script of your work with the upload of files?

Thanks again,

John
Quote Reply
Re: [jgold723] File name length limitation In reply to
Unix is replacing the spaces with %20.

Your file names are getting truncated to 65 or 64 characters depending on how you count them, but it seems consistent.

Check your config file and INPUT tags to see if you don't have a field limit somewhere. Also check the MOD to see if there is something in there like that.
Quote Reply
Re: [Watts] File name length limitation In reply to
That certainly makes sense, but for the life of me, I can't find any coding in the script, mod, config file or HTML file that would truncate the file name.

The input field for the file upload is 50 characters in size, but there is no MAXSIZE attribute coded in there.

Any suggestions as to where something like this might be hiding?

John
Quote Reply
Re: [jgold723] File name length limitation In reply to
Check out this thread:

Topic: remove spaces from uploaded files how? ( file upload mod )
beaverbeacon
http://gossamer-threads.com/p/251834

------

To set a maximum field length try changing:

<INPUT TYPE="FILE" NAME="file-to-upload-$u" SIZE="50">

to (for example):

<INPUT TYPE="FILE" NAME="file-to-upload-$u" SIZE="50" MAXLENGTH="60">

You may also want to place a note to users to let them know about the maximum length allowed for the filename.

I couldn't find anything else in my limied search of the FAQ on how else to control the length of the file being uploaded. I think it might be easiest to just have the users rename the very long filenames to fit within the field.

Hope this helps

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] File name length limitation In reply to
Quote:
I think it might be easiest to just have the users rename the very long filenames to fit within the field

Yep. Lois is right. You have to admit, 60+ character file names are kind of extreme.

FYI, I uploaded a *really long* file name (complete with spaces) to one of our unix servers and it didn't seem to bother it any. Must be something else that's causing the problem.

I looked through the multiple file upload mod to see if I could spot any kind of limitations, but I didn't see anything there. Sorry.

<scratches head>Unsure

Last edited by:

Watts: Dec 2, 2004, 3:37 PM