OK już podaje korzystam z xampp C:\xampp\htdocs(jeżeli miało by to w czymś pomóc) teraz struktura katalogów projektu:
-----------
testy -application
--configs
--controllers
---kontrolery.php
--forms
---formularze.php
--layouts
---layout.phtml
--models
---modele.php
--plugins
---pluginy.php
--views
---helpers
---scripts
----index
-----index.phtml
Bootstrap.php
-library
-public
--------------
Jeżeli mało czytelnie mogę poprawić(chyba znasz tą strukturę).
[EDIT]
Ok coś ruszyłem ale jeszcze nie jest to o co mi chodzi plik się przesłał do podanej lokalizacji ale nie zmienił nazwy
Kod formularza:
CODE
<?php
class Form_Addsala extends Zend_Form
{
public function __construct($options = null)
{
parent::__construct($options);
$this->setName('Sala');
$this->setAttrib('enctype', 'multipart/form-data');
$plik = new Zend_Form_Element_File('foo');
$plik->setLabel('Upload an image:')
->setDestination('../../testy/');
$plik->addValidator('Count', false, array('min' => 1, 'max' => 6));
$plik->addValidator('Size', false, 102400);
$plik->addValidator('Extension', false, 'jpg,png,gif');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Wyślij');
$this->addElements(array( $plik, $submit ));
$this->setMethod('post');
$this->setAction(Zend_Controller_Front::getInstance()->getBaseUrl().'/addsala/index');
}
}
Kod kontrolera:
CODE
<?php
class AddsalaController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$request = $this->getRequest();
$form = new Form_Addsala();
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($form->isValid($formData)) {
/* Uploading Document File on Server */
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination("../../testy/");
try {
// upload received file(s)
$upload->receive();
} catch (Zend_File_Transfer_Exception $e) {
$e->getMessage();
}
// so, Finally lets See the Data that we received on Form Submit
$uploadedData = $form->getValues();
Zend_Debug::dump($uploadedData, 'Form Data:');
// you MUST use following functions for knowing about uploaded file
# Returns the file name for 'doc_path' named file element
$name = $upload->getFileName('doc_path');
# Returns the size for 'doc_path' named file element
# Switches of the SI notation to return plain numbers
$upload->setOption(array('useByteString' => false));
$size = $upload->getFileSize('doc_path');
# Returns the mimetype for the 'doc_path' form element
$mimeType = $upload->getMimeType('doc_path');
// following lines are just for being sure that we got data
print "Name of uploaded file: $name
";
print "File Size: $size
";
print "File's Mime Type: $mimeType";
// New Code For Zend Framework :: Rename Uploaded File
$renameFile = 'newName.jpg';
$fullFilePath = '/images/'.$renameFile;
// Rename uploaded file using Zend Framework
$filterFileRename = new Zend_Filter_File_Rename(array('target' => $fullFilePath, 'overwrite' => true));
$filterFileRename -> filter($name);
exit;
}
} else {
// this line will be called if data was not submited
$form->populate($formData);
}
}
}
Na stronie wyświetla informacje:
Kod
Form Data: array(2) {
["foo"] => string(11) "dj-logo.gif"
["submit"] => string(7) "Wyślij"
}
Fatal error: Call to undefined method Zend_File_Transfer_Adapter_Http::setOption() in C:\xampp\htdocs\testy\application\controllers\AddsalaController.php on line 40
Chyba chodzi o to że nie może zidentyfikować metody Zend_File_Transfer_Adapter_Http.