Gossamer Forum
Home : Products : Gossamer Links : Discussions :

regex for file column

Quote Reply
regex for file column
Hello

what regex do you need to set only .jpg, .png & .gif files to be uploaded???

I have added:

'regex' => '\.(gif|jpg|png)$'

but in add.cgi & modify.cgi I get this error message:

File can not contain the value ''

what do I wrong????????

Quote Reply
Re: regex for file column In reply to
Hi,

The regex is correct. This does force someone to upload a file though. If you want gif/jpg or nothing, try:

regex => '^|.*\.(gif|jpg|png)$'

which should work I think.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: regex for file column In reply to
 
As devil's advocate,

regex => '^|.*\.(gif|jpg|png)$'

Doesn't handle the case of filename.GIF does it?



PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: regex for file column In reply to
Thank you Alex

it works, but the admin can't see the file with the validation.

Quote Reply
Re: regex for file column In reply to
 
Alex,

I tried your regex info in my image upload column, and it doesn't allow me to upload files. It says "filename.jpg" is not allowed (it lists the actual filename). Is this what you meant pugdog?

Last edited by:

Evoir: Sep 10, 2001, 2:38 PM
Quote Reply
Re: [Alex] regex for file column In reply to
I know I posted this a long time ago... but I just started working on our database again and am finding I have the same error when using

Code:
'^|.*\.(gif|jpg|png)$'

When I try to upload an image from the browser. It says something like "Image for detailed page cannot contain a name of cvr.jpg

Is there something wrong with this form regex?
Quote Reply
Re: [Evoir] regex for file column In reply to
^|.*\.(gif|jpg|png)$

If I'm reading that correctly, the pipe character is an alternation character (or), so with nothing to it's left, it means it will match a null string, or, on it's right it will match zero or more characters followed by a period, followed by one of gif , jpg or png which would terminate the string (the string must END in a .gif, .png, or .jpg)

My question is that would this be case sensitive or insensitive, in which case it would NOT match .GIF.

In perl, that would be putting a 'i' at the end of the pattern match.

And, since you want there to be _SOME_ file name, not just an extension, shouldn't the match really be:

^|.+\.(gif|jpg|png)$

for one or more matches?

These are my questions :)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Post deleted by Paul In reply to

Last edited by:

Paul: Mar 17, 2002, 2:09 AM
Quote Reply
Re: [Evoir] regex for file column In reply to
Are you wanting the file to be optional?

Something like this may work:

^|[\w-]+\.(gif|GIF|jpg|JPG|png|PNG)$

Last edited by:

Paul: Mar 17, 2002, 2:11 AM