problem with file uploads using quickform
| From: | Charles Kline | Date: | Thu, 08 Mar 2007 08:21:39 +0000 |
| Subject: | problem with file uploads using quickform | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-26776@lists.php.net to get a copy of this message | ||
hi all.
i am having a problem accessing the name of the file being uploaded. the file uploads just fine, but i can't seem to get the name to add to my sql query.
Note, I have tired using print_r($values) inside the process_data function and it does not display any of the info about the file.
thanks,
charles
here is my code:
require_once 'HTML/QuickForm.php';
$form = new HTML_QuickForm('port_form', 'post');
<snip>
$file =& $form->addElement('file', 'port_image', 'Portfolio Company Banner');
$form->addElement('submit', null, 'Update');
$form->addRule('port_image', 'You must select a file', 'uploadedfile');
//$form->addRule('port_image', 'Must be a JPG', 'mimetype', array('image/jpeg', 'image/jpeg'));
// Try to validate a form
if ($form->validate()) {
//$form->freeze();
$form->process('process_data', false);
//exit;
} else {
$form->display();} function process_data ($values) {
$path = "/home/mysite/uploads/";$dbq = new dbquery; global $file; if($file->isUploadedFile()) { $file->moveUploadedFile($path); $port_id = $dbq->set_port_update($values['port_id'],$values['port_company'],$values['port_desc'],$values['port_url'],$values['port_image']['name']);
echo "Updated and File Uploaded<br />";
} elseif ($dbq->set_port_update($values['port_id'],$values['port_company'],$values['port_desc'],$values['port_url'])){
echo "Updated<br />";
} else {
print " No action performed";
}
}