PHP Classes

Regex pb with uploading

Recommend this page to a friend!

      PHP Forms Class with HTML Generator and JavaScript Validation  >  PHP Forms Class with HTML Generator and JavaScript Validation package blog  >  Locating addresses on...  >  All threads  >  Regex pb with uploading  >  (Un) Subscribe thread alerts  
Subject:Regex pb with uploading
Summary:I can't validate my upload on the server side
Messages:2
Author:Gruselle
Date:2007-01-18 15:49:37
Update:2007-01-18 17:26:49
 

  1. Regex pb with uploading   Reply   Report abuse  
Picture of Gruselle Gruselle - 2007-01-18 15:49:37
Hi,

I'm a newbie in PHP, and I got a problem with my form. I want users to upload DV file only. So I use that :

$form->AddInput(array(
'TYPE'=>'file',
'NAME'=>'userfile',
'ValidateOnlyOnClientSide'=>1,
'ValidateRegularExpression'=>'\.(dv|DV|Dv|dV)$',
'ValidateRegularExpressionErrorMessage'=>'Wrong file',
'ValidateAsNotEmpty'=>1,
'ValidationErrorMessage'=>'It was not specified a valid file to upload'
));

When the validation on the server side is enable, it always says that the file is wrong. It works with Javascript only but it seems to me that this validation alone is a little bit "light".

Does anyone have the same problem ? Is my regular expression incorrect ?

Thanks in advance.

  2. Re: Regex pb with uploading   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-01-18 17:26:49 - In reply to message 1 from Gruselle
Using regular expressions to validate file inputs does not make much sense because the value to be validated is the contents of the file, not the file name.

To validate the file name itself, you would need to implement a custom server side validation function or develop a custom plug-in to perform new types of validation that you need.