In PHP there is a function called "basename" which returns the filename from an complete directory string.

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

----- Original Message ----- From: "Ace Paul" <[EMAIL PROTECTED]>
To: <fw-general@lists.zend.com>
Sent: Friday, November 14, 2008 7:37 AM
Subject: [fw-general] insert filename without path into database



My form intem looks like this

    $element = new Zend_Form_Element_File('logo_image');
$element->setLabel('Logo Image:')
->setRequired('true')
       ->setDestination('/home/pathto/images/logos/')
       ->addValidator('Count', false, 1)     // ensure only 1 file
       ->addValidator('Size', false, 5002400) // limit to 100K
       ->addValidator('Extension', false, 'jpg,png,gif'); // only JPEG,
PNG, and GIFs
$this->addElement($element, 'logo_image');

            // add the comment element
       $this->addElement('hidden', 'logo_business', array(
       ));

and it is inserted into db like this


function addlogoAction()
{
$this->view->title = "Add New Logo";
$form = $this->_getLogoForm();

       if (!$this->getRequest()->isPost()) {
           $this->view->LogoForm = $form;

$form->getElement('logo_business')->setValue($this->_request->getParam('logo_business'));
           return;
       } elseif (!$form->isValid($_POST)) {
           $this->view->failedValidation = true;
           $this->view->LogoForm = $form;
           return;
       }

       $values = $form->getValues();
       $table = new Logos();
      $imagepath = $values['logo_image'];

       $data = array(
           'logo_name' => $values['logo_name'],
           'logo_image' => $values['logo_image'],
           'logo_business' => $values['logo_business']
       );

       $table->insert($data);
      $this->view->LogoSaved = true;

}


how do i go about only storing the file name in the database instead of the
entire path and filename. thanks for any help
--
View this message in context: http://www.nabble.com/insert-filename-without-path-into-database-tp20495425p20495425.html Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to