Zebra Form upload plików

0

Witam mam problem z wstawieniem pola do upload pliku z formularza poprzez clase zebra form
http://stefangabos.ro/php-libraries/zebra-form/ - link do dokumentacji mój kod

// create a new form
$form = new Zebra_Form('my_form');
 
// add a file upload control to the form
// the "&" symbol is there so that $obj will be a reference to the object in PHP 4
// for PHP 5+ there is no need for it
$obj = &$form->add('file', 'my_file_upload');
 
// don't forget to always call this method before rendering the form
if ($form->validate()) {
 
    // all the information about the uploaded file will be
    // available in the "file_upload" property
    print_r('<pre>');
    print_r($form->file_upload['my_file_upload']);
 
}
 
// output the form using an automatically generated template
$form->render();

Fatal error: The control named "my_file_upload" in form "Szablony" must have the "upload" rule set in formularz.php on line 169

Ma ktoś jakiś pomysl jak to rozwiązać

0

JA za CIEBIE musiałem czytać MANUAL...

W tej klasie możesz (i jak widać - czasem musisz) definiować reguły wg których walidowane będą pola formularza. Więcej o definicji regułek: http://stefangabos.ro/wp-content/docs/Zebra_Form/Generic/Zebra_Form_Control.html#methodset_rule
Pola formularza zawierające pliki MUSZĄ mieć regułkę upload.

0

Ale jestem głupiiiiii dzieki za pomoc.

0

Sorki ale jeszcze mam problam użyłem uploadu i ciągle wywala mi że nie przechodzi walidacji rozwiązał ktoś taki problem

$obj = &$form->add('file', 'Logo');

$obj->set_rule(array(

    
    'upload' => array(
        'zebra',                              // path to upload file to
        ZEBRA_FORM_UPLOAD_RANDOM_NAMES,     // upload file with random-generated name
        'error',                            // variable to add the error message to
        'File could not be uploaded!'       // error message if value doesn't validate
     ),
));

Nie przechodzi mi walidacji obojetni jaki plik dodam jak zbuduje przez normlany formularz dodanie pliku to widać go a tutaj jest bład File could not be uploaded

Co to za funkcja ZEBRA_FORM_UPLOAD_RANDOM_NAMES

Lub bład lezy ze operacji nie można wykonać po stronie serwera ale to jak to zrobić jak daje zwykla opcje w html to wchodzi tak jakby plik zaladowany atutaj nic

1 użytkowników online, w tym zalogowanych: 0, gości: 1