Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.2

Bug #423 Form file uploading bug.
Submitted: 2003-12-14 22:47 UTC
From: krisc79 at tlen dot pl Assigned: mw21st
Status: Closed Package: DB_DataObject_FormBuilder
PHP Version: 4.3.4 OS: XP
Roadmaps: (Not assigned)    
Subscription  


 [2003-12-14 22:47 UTC] krisc79 at tlen dot pl
Description: ------------ Bug in database update/insert field when uploading file from form input file control. My Fix: function processForm($values) { .... foreach ($values as $field=>$value) { $this->debug("Field $field "); if (in_array($field, array_keys($this->_do->table()))) { if (is_array($value)) { $this->debug(" (converting date) "); /******* KRISC ADDITION FOR CORRECT FILE UPLOADS 27_11_2003 *****/ $this->debug(" file array also! "); //print_r ($value); if (isset($value['tmp_name'])) $value = $value['name']; else $value = $this->_array2date($value); } $this->_do->$field = $value; $this->debug("is substituted with '$value'.\n"); } else { $this->debug("is not a valid field.\n"); } } ..... }

Comments

 [2003-12-31 00:19 UTC] mw21st at php dot net
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.
 [2004-06-06 23:09 UTC] fsteinel
see patch for File upload support. the script using DB_DataObject_Formbuilder MUST add folowing code to validate if ($form->validate()) { ... $file =& $form->getElement('Quickform_fieldname'); $file->moveUploadedFile('/destdir/'); ... } without no file won't be moved anywhere. (preprocess -> preProcess is pearQA php4 php5) Quickform_fieldname = name of Field (type file) --- Index: FormBuilder.php =================================================================== --- FormBuilder.php (revision 34) +++ FormBuilder.php (revision 35) @@ -483,6 +483,9 @@ } elseif (isset($this->_do->textFields) && is_array($this->_do->textFields) && in_array($key,$this->_do->textFields)) { $element =& HTML_QuickForm::createElement($this->_getQFType('longtext'), $key, $this->getFieldLabel($key)); + } elseif (isset($this->_do->uploadFields) && is_array($this->_do->uploadFields) && + in_array($key,$this->_do->uploadFields)) { + $element =& HTML_QuickForm::createElement('file', $key, $this->getFieldLabel($key)); } else { // Auto-detect field types depending on field's database type switch (true) { @@ -614,7 +617,8 @@ function &_createDateElement($name) { global $_DB_DATAOBJECT_FORMBUILDER; - $dateOptions = array('format' => $_DB_DATAOBJECT_FORMBUILDER['CONFIG']['date_element_format']); + $dateOptions = array('format' => $_DB_DATAOBJECT_FORMBUILDER['CONFIG']['date_element_format'], + 'language' => $this->_dateFieldLanguage); if (method_exists($this->_do, 'dateoptions')) { $dateOptions = array_merge($dateOptions, $this->_do->dateOptions($name)); } @@ -1084,7 +1088,7 @@ function processForm($values) { $this->debug("<br>...processing form data...<br>"); - if (method_exists($this->_do, 'preprocess')) { + if (method_exists($this->_do, 'preProcess')) { $this->_do->preProcess($values); } @@ -1325,4 +1329,4 @@ } } -?> \ No newline at end of file +?>