Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

QuickForms: error in client validation uploading a file
Hi,

I have a form with two rules like these:

------------------------------------------------------------------------
$this->file =& $this->addElement('file', 'userfile', 'Imagen:(max:1MB)',
array('size'=>50, 'maxlength'=>100));
$this->file2 =& $this->addElement('file', 'userfile2',
'Documento:(max:2MB)', array('size'=>50, 'maxlength'=>100));
------------------------------------------------------------------------

and two rules:

------------------------------------------------------------------------
$this->addRule('userfile', 'El fichero de imagen es demasiado grande.',
'maxfilesize', 1048576,'client');
$this->addRule('userfile2', 'El fichero es demasiado grande.',
'maxfilesize', 2097152,'client');
------------------------------------------------------------------------

that generates this piece of java script:

------------------------------------------------------------------------
86 value = frm.elements['userfile'].value;
87 if (value != '' && !_ruleCheckMaxFileSize(value, '1048576') && !errFlag['
userfile']) {
88    errFlag['userfile'] = true;
89    _qfMsg = _qfMsg + '\n - El fichero de imagen es demasiado grande.';
90 }
91
92 value = frm.elements['userfile2'].value;
93 if (value != '' && !_ruleCheckMaxFileSize(value, '2097152') && !errFlag['
userfile2']) {
94    errFlag['userfile2'] = true;
95    _qfMsg = _qfMsg + '\n - El fichero es demasiado grande.';
96 }
------------------------------------------------------------------------

and at last the browser get me this error message:

------------------------------------------------------------------------
Error: _ruleCheckMaxFileSize is not defined
Source File: ...
Line: 93
------------------------------------------------------------------------

(at the second call!!) and the client validation is not done at all.


Anyone with any ideas? I didn't find anything out there.

Thanks.
Toni.

Report this thread to moderator Post Follow-up to this message
Old Post
Toni
11-29-04 09:04 PM


Re: QuickForms: error in client validation uploading a file
quote:
Originally posted by Toni Hi, I have a form with two rules like these: ------------------------------------------------------------------------ $this->file =& $this->addElement('file', 'userfile', 'Imagen:(max:1MB)', array('size'=>50, 'maxlength'=>100)); $this->file2 =& $this->addElement('file', 'userfile2', 'Documento:(max:2MB)', array('size'=>50, 'maxlength'=>100)); ------------------------------------------------------------------------ and two rules: ------------------------------------------------------------------------ $this->addRule('userfile', 'El fichero de imagen es demasiado grande.', 'maxfilesize', 1048576,'client'); $this->addRule('userfile2', 'El fichero es demasiado grande.', 'maxfilesize', 2097152,'client'); ------------------------------------------------------------------------ that generates this piece of java script: ------------------------------------------------------------------------ 86 value = frm.elements['userfile'].value; 87 if (value != '' && !_ruleCheckMaxFileSize(value, '1048576') && !errFlag[' userfile']) { 88 errFlag['userfile'] = true; 89 _qfMsg = _qfMsg + '\n - El fichero de imagen es demasiado grande.'; 90 } 91 92 value = frm.elements['userfile2'].value; 93 if (value != '' && !_ruleCheckMaxFileSize(value, '2097152') && !errFlag[' userfile2']) { 94 errFlag['userfile2'] = true; 95 _qfMsg = _qfMsg + '\n - El fichero es demasiado grande.'; 96 } ------------------------------------------------------------------------ and at last the browser get me this error message: ------------------------------------------------------------------------ Error: _ruleCheckMaxFileSize is not defined Source File: ... Line: 93 ------------------------------------------------------------------------ (at the second call!!) and the client validation is not done at all. Anyone with any ideas? I didn't find anything out there. Thanks. Toni.
This is simply a bug with the client-side validation of file elements in HTML_Quickform . The bug was reported here: http://pear.php.net/bugs/bug.php?id=134 The problem is that _ruleCheckMaxFileSize is a PHP function (not a javascrip t function). However, the recommendation from the PEAR site is to simply no t use client-side validation for file elements. Hope that helps.

Report this thread to moderator Post Follow-up to this message
Old Post
rssaddict
06-29-06 07:23 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Pear archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:06 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.