przewiń do treści

Zend Framework od podstaw

Włodzimierz Gajda

<?php
class Application_Form_Plik extends Zend_Form
{
  public function init()
  {
    $this->setMethod('post');
    $element = new Zend_Form_Element_File('slug', array('required' => true));
    $element
      ->setLabel('Dodaj plik:')
      ->setDestination(realpath(APPLICATION_PATH . '/../public/uploads'))
      ->addValidator('NotEmpty', true)
      ->addValidator('Count', true, 1)
      ->addValidator('Size', true, 1024000)
      ->addValidator('NotExists', realpath(APPLICATION_PATH . '/../public/uploads'));
    $this->addElement($element, 'slug');
    $this->addElement('submit', 'submit', array(
      'label' => 'Zapisz',
    ));
  }
}

Listing 31.7. Formularz Plik z przykładu 31.2

Rozdział 31. Przesyłanie plików na serwer

listing-31-07.txt