Re: QuickForm and files.

From: Date: Tue, 04 Nov 2003 08:04:56 +0000
Subject: Re: QuickForm and files.
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-8747@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday 04 November 2003 7:36 am, Alexey Borzov wrote: > Use the methods of HTML_QuickForm_file class. The deprecated methods will > be removed in 3.2, due out very soon. Thanks for the help! Just so that I know if I'm doing it in the 'best' way, can anyone comment on this code snippit? (the form processing stuff will be moved into the form class when it's finished). This code does work, I just want to ensure that I'm using the class as intended! Kind Regards, $form = new Form_addShop(); if ($form->Validate()) { $newShop = new DataObjects_shop(); $newShop->Name = $form->exportValue('txtName'); $newShop->Description = $form->exportValue('txtDescription'); $newShop->insert(); echo "Id: " . $newShop->Id . "<br />"; if ($form->isUploadedFile('fileImage')) { $fileImage = $form->getElement('fileImage'); $fileInfo = $fileImage->getValue(); $binary = file_get_contents($fileInfo['tmp_name']); $newImage = new DAtaObjects_Image(); $newImage->Type = 'shop'; $newImage->ObjectId = $newShop->Id; $newImage->Data = $binary; $newImage->ContentType = $fileInfo['type']; $newImage->Filename = $fileInfo['name']; $newImage->insert(); } } else { $form->display(); } - -- Ian P. Christian - pookey@pookey.co.uk - +44 (0) 7740 189415 - http://www.pookey.co.uk/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/p12oEe6ncNCcEO0RAq7BAJ9A8ZTqG/chPMTWJms7OdEuLw0JogCgwV4M sTIi2wvitTQHHyl+St7krCU= =NaB6 -----END PGP SIGNATURE-----

« previous php.pear.general (#8747) next »