Re: QuickForm - missing $_FILES data

From: Date: Fri, 04 Apr 2003 20:40:52 +0000
Subject: Re: QuickForm - missing $_FILES data
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4653@lists.php.net to get a copy of this message
<bfaulls@omphe.com> wrote : > Trying to use Quickform as part of an image upload script. When I try > to access the uploaded file in the $_FILES array, it is always empty. > Using a simple form of my own, I am able to access the $_FILES data > without fail. > > var_dump($_FILES); with a QuickForm returns nothing. > > Do I have to reinstatiate the same QuickForm inorder to process the > form data? The Quickform source code doesn't point to this. Very > confused here. > > Sample Code > ----------------------------------------- > <?php > > require_once('myAuth.php'); //an instantiation of Auth > require_once('HTML/QuickForm.php'); > > //if myAuth.php finds the user is authenticated > // > it will call this function > function page_content() > { > > if(!$_FILES['imgfile']) { > upload_form('No file uploaded!'); > } > else { > > /********************************************* > * validate the image > ********************************************/ > > } > } > > > //no post data, show form > function upload_form($errMsg) > { > > $page = new HTML_Page(); > > $form = new HTML_QuickForm('img_upl', 'post'); > > $img = &HTML_QuickForm::createElement('file','imgfile'); > > $smb = &HTML_QuickForm::createElement('submit', null, 'Submit'); > > $form->addHeader('Enter image to upload:'); > $form->addElement($img); It's probably because the form is not updated with the 'enctype' and 'hidden maxfilesize' that are necessary for file uploads. The easy solution would be to use: $form->addElement('file', 'imgfile'); instead of the createElement above. Otherwise, you will have to set the form attributes and the hidden field manually. Tell me if it worked. Bertrand Mansion Mamasam

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