This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » symfony 1.3 and 1.4 » How can I check if a file exist or not?
How can I check if a file exist or not? [message #102518] Thu, 15 July 2010 12:05 Go to next message
apulmca2k4  is currently offline apulmca2k4
Messages: 123
Registered: August 2008
Location: New Delhi, India
Senior Member
Hi,

I am currently using sfValidatorFile to validate & upload the image.

Now, I want to check if that file already exist or not & throw the error accordingly.

Please suggest.


Apul Gupta
http://in.linkedin.com/in/apulgupta
Re: How can I check if a file exist or not? [message #102524 is a reply to message #102518 ] Thu, 15 July 2010 13:14 Go to previous messageGo to next message
johnny.lattouf  is currently offline johnny.lattouf
Messages: 44
Registered: September 2009
Member
The filename saved is auto generated, so you can't check if a file already exists with its name.
sfValidatorFile uses validated_file_class sfValidatedFile, you can check it.

Then you can assign an option to sfValidatorFile 'validated_file_class' => myCustomValidatedFile and do whatever you want.


Johnny Lattouf
Re: How can I check if a file exist or not? [message #102526 is a reply to message #102524 ] Thu, 15 July 2010 13:37 Go to previous message
apulmca2k4  is currently offline apulmca2k4
Messages: 123
Registered: August 2008
Location: New Delhi, India
Senior Member
Hi,

Thanks for reply.

How can I get, that which model class to check for the file? because this validator will be used at many places in application.

How can I pass model name to the validator "myCustomValidatedFile"?

Please suggest.


Apul Gupta
http://in.linkedin.com/in/apulgupta
Previous Topic:[SOLVED]sfValidatorAnd and null objects?
Next Topic:Can $object->getRelation() return a doctrine query ?
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software