Hi Thomas,

Thank you for your quick reply.
I downloaded 1.7 and use it currently.

Secondly i'm new to PHP (saw my first code two weeks ago)
Basically what i try to do is upload a file (perhaps at first even without
validation) and i'm not been able to do that so far.
The reason i added the validations is because this seems a logical way to do
but my main goal so far is succeed in uploading a file.
So in order to reach that goal i stripped all the validations in order to
remove al the clutter so this is what i have so far in the user form:
public function __construct($options = null) 
    { 

        parent::__construct($options);
        $this->setName('upload');
        $this->setAttrib('enctype', 'multipart/form-data');
        $description = new Zend_Form_Element_Text('description');
        $description->setLabel('Description')
                  ->setRequired(true)
                  ->addValidator('NotEmpty');

                  
        $file = new Zend_Form_Element_File('file');
        $file->setLabel('File')
                                        
->setDestination('/Applications/MAMP/htdocs/questimmo/tmp')
                    ->addFilter('Rename',
'/Applications/MAMP/htdocs/questimmo/tmp')
                    ->setRequired(true);
//                    ->addValidator('Count', false, 1) // ensure only 1
file
//                    ->setMaxFileSize(10 * 1024 * 1024) // limit to 10M
//                    ->addValidator('FilesSize', true, '10MB')
//                    ->addValidator('Extension', true, 'png'); // PNG

                 
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Upload');
        Utils::log('adding the upload elements',1);
        $this->addElements(array($description, $file, $submit));
            

    } 
and this in the controller:
        function indexAction()
        {


                $this->view->title = "Zend_Form File Upload Test";
                $this->view->baseUrl = $this->_request->getBaseUrl();
                $form = new UploadForm();
                $this->view->form=$form;

                if ($this->_request->isPost()) {
                        $postValues = $this->_request->getPost();
                        if (!empty($postValues) && $form->isValid($postValues)) 
{
                        }
                        var_dump($_FILES, $form->getErrors(), 
$form->getValues());
                }
        }

when i try to upload a file i get these error messages:

Notice: Undefined index: tmp_name in
/Applications/MAMP/htdocs/questimmo/library/Zend/File/Transfer/Adapter/Abstract.php
on line 583
Notice: Undefined index: name in
/Applications/MAMP/htdocs/questimmo/library/Zend/Validate/File/Upload.php on
line 152
Notice: Undefined index: tmp_name in
/Applications/MAMP/htdocs/questimmo/library/Zend/Validate/File/Upload.php on
line 156
Notice: Undefined index: error in
/Applications/MAMP/htdocs/questimmo/library/Zend/Validate/File/Upload.php on
line 169
Notice: Undefined index: tmp_name in
/Applications/MAMP/htdocs/questimmo/library/Zend/Validate/File/Upload.php on
line 171
array(0) { } array(3) { ["description"]=> array(0) { } ["file"]=> array(1) {
[0]=> string(21) "fileUploadErrorAttack" } ["submit"]=> array(0) { } }
array(3) { ["description"]=> string(8) "Test" ["file"]=> NULL ["submit"]=>
string(6) "Upload" } 


TIA

Marc Gobel


thomasW wrote:
> 
> First:
> Please use 1.7 and not 1.7PR. There has really much changed since the past 
> releases.
> 
> Second:
> You should validate your input before receiving the files.
> Otherwise the receivment will fail because you can not receive files which 
> fail validation.
> What should be the reason for adding a validator when you don't validate 
> something. :-)
> 
> For me it looks like you tried to receive the files and there were no
> files 
> given.
> 
> Greetings
> Thomas Weidner, I18N Team Leader, Zend Framework
> http://www.thomasweidner.com
> 
> ----- Original Message ----- 
> From: "MarcG" <[EMAIL PROTECTED]>
> To: <fw-general@lists.zend.com>
> Sent: Monday, November 17, 2008 10:18 AM
> Subject: [fw-general] Not able to get file upload to be working
> 
> 
>>
>> Hi,
>>
>> I want to upload several pictures, and i try to use the
>> Zend_Form_Element_File.
>> These are the error messages i get:
>>
>> Notice: Undefined index: tmp_name in
>> /library/Zend/File/Transfer/Adapter/Abstract.php on line 577
>> Warning: Invalid argument supplied for foreach() in
>> /library/Zend/Validate/File/Count.php on line 217
>> Notice: Undefined index: tmp_name in
>> /library/Zend/File/Transfer/Adapter/Abstract.php on line 577
>> Warning: Invalid argument supplied for foreach() in
>> /library/Zend/Validate/File/FilesSize.php on line 94
>> Notice: Undefined index: tmp_name in
>> /library/Zend/File/Transfer/Adapter/Abstract.php on line 577
>> Notice: Undefined index: name in
>> /library/Zend/Validate/File/Extension.php
>> on line 198
>>
>> What am i doing wrong?
>>
>> In my form i have:
>>        $file = new Zend_Form_Element_File('file');
>>        $file->setLabel('File')
>>                    ->setDestination('/tmp')
>>                    ->addFilter('Rename', '/tmp/')
>>                    ->setRequired(true)
>>                    ->addValidator('Count', false, 1) // ensure only 1
>> file
>>                    ->setMaxFileSize(10 * 1024 * 1024) // limit to 10M
>>                    ->addValidator('FilesSize', true, '10MB')
>>                    ->addValidator('Extension', true, 'png'); // PNG
>>
>> in my controller i have:
>>
>>
>>    $this->view->title = "Zend_Form File Upload test";
>>        $this->view->baseUrl = $this->_request->getBaseUrl();
>>
>>        $form = new UploadForm();
>>
>>        if ($this->_request->isPost()) {
>>             $formData = $this->_request->getPost();
>>
>>                // success - do something with the uploaded file
>>                $uploadedData = $this->_request->getPost('file');
>>
>>       $adapter = $form->file->getTransferAdapter()
>>        try {
>>                $adapter->receive();
>> //<-- here it goes wrong...
>>        } catch (Zend_File_Transfer_Exception $e) {
>>        Utils::log($e->getMessage());
>>                $e->getMessage();
>>        }
>>
>> the version i currently use is 1.6.2 but i also tried to use 1.6.1 and
>> 1.7.0PR
>>
>> I hope anybody can help me or can supply me with a working sample.
>>
>> TIA
>>
>> Marc Gobel
>>
>>
>>
>>
>>
>>
>>
>> -- 
>> View this message in context: 
>> http://www.nabble.com/Not-able-to-get-file-upload-to-be-working-tp20536045p20536045.html
>> Sent from the Zend Framework mailing list archive at Nabble.com. 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Not-able-to-get-file-upload-to-be-working-tp20536045p20551082.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to