-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm using the following class for a form with an image in, but I need to use a
function to validate that an image was uploaded with the correct type and
that it's not too large.
I don't seem to be able to access the information about the file from within
the class witrhout using the $_FILES array. Does anyone have any ideas?
<?php
require_once 'HTML/QuickForm.php';
class Form_addShop extends HTML_QuickForm
{
function Form_addShop($formName='addShop', $method = 'post', $target =
'_self', $attributes = null)
{
$this->HTML_QuickForm($formName, $method, '', $target, $attributes);
$this->addElement('header', null, 'Add a Shop');
$this->addElement('text', 'txtName', 'Name', array('size'=>20,
'maxlength'=>50));
$this->addElement('textarea', 'txtDescription', 'Description');
$this->addElement('file', 'fileImage', 'Image');
$this->addElement('submit', null, 'Submit');
$this->applyFilter('txtName', 'trim');
$this->applyFilter('txtDescription', 'htmlspecialchars');
$this->addRule('txtName', 'Name is required', 'required', null,
'server');
$this->addRule('txtDescription', 'Description is required', 'required',
null, 'server');
$this->addFormRule(array(&$this,'CheckUpload'));
}
function CheckUpload($stuff)
{
// shows MAX_FILE_SIZE
var_dump($stuff);
// shows nothing (probably due to form not having completed validation
var_dump($this->exportValue('fileImage'));
// shows what Iwant
var_dump($_FILES);
return array('fileImage' => 'This is not an image');
}
}
?>
Kind Regards,
- --
Ian P. Christian
- [EMAIL PROTECTED]
- +44 (0) 7740 189415
- http://www.pookey.co.uk/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQE/poCXEe6ncNCcEO0RAuoKAJ9KaX06C294btAyTiLI/XVWecrrqACglSiH
ls8Fnw/i89euWHWp5F/WQ20=
=NBo0
-----END PGP SIGNATURE-----
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php