For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > October 2007 > [DB_DataObject_FormBuilder & HTML_QuickForm] File upload handling









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author [DB_DataObject_FormBuilder & HTML_QuickForm] File upload handling
Thomas Murphy

2007-10-11, 4:08 am

Hello,

I'm fairly familiar with PEAR packages however I'm a bit stuck when it
comes to managing file uploads using DB_DataObject +
DB_DataObject_FormBuilder + HTML_QuickForm.

In my form when I submit a file (which is optional in the form) I can
move the uploaded file no problems in DataObject::preProcessForm() with
the following code

// check for uploaded file
if($fb->_do->fb_preDefElements['program_pdf']->isUploadedFile())
{
if(!$fb->_do->fb_preDefElements['program_pdf']->moveUploadedFile($_SERVER['PROGRAM']))
{
print 'Failed to upload file';
}
}

and processForm() does the rest automatically to insert the program_file
filename into the DB.

Now my problem is when I go back to the form to edit some fields without
uploading a new file, the processForm() erases the file upload record
because there is no $_REQUEST['program_pdf'].
So I'm looking for tips on how to manage all this without having to
write my custom processForm callback method.

Cheers,
Tom
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com