Re: Re: Quickform - File uploads

From: Date: Tue, 02 Sep 2003 13:49:59 +0000
Subject: Re: Re: Quickform - File uploads
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-7538@lists.php.net to get a copy of this message
It works! Lovely. Thank you for the suggestions. Leonie "Bertrand Mansion" <bmansion@mamasam.com> wrote in message news:BB7A1006.C1D2%bmansion@mamasam.com... <leonie_price@hotmail.com> wrote : > Just so you know, here is my code so far: > > $form = new HTML_QuickForm('import_excel', 'post'); > $form->addElement('file', 'xls_file', 'File:'); $file =& $form->addElement('file', 'xls_file', 'File:'); Keep a reference to the file element to be able to work with it later. > $form->addRule('xls_file', 'You must select a file', > 'required'); $form->addRule('xls_file', 'You must select a file', 'uploadedfile'); Required is called uploadedfile for file elements. > $form->addElement('submit', 'btnUpload', 'Upload'); > if ($form->validate()) { > # If the form validates then freeze the data > $form->freeze(); There is no freeze for file elements. Unless you can tell me how it should look like when frozen. > $form->process('process_data', false); > } > else { > $form->display(); > } > > function process_data($values) { > global $form; Here you can make $file global instead. > if ($form->isUploadedFile('xls_file')) { if ($file->isUploadedFile()) { > $x = $form->moveUploadedFile('xls_file', 'E:/temp'); $x = $file->moveUploadedFile('E:/temp'); > print $x; > } > else > { > print "No file uploaded"; > } > } > > > Works ok, but it would be nice to fix up the validation. Hope this helps Bertrand Mansion Mamasam

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