File upload problem:(

7 messages Options
Embed this post
Permalink
robos85

File upload problem:(

Reply Threaded More More options
Print post
Permalink
I have that code in my controller:
$destination = PUBLIC_PATH.'/obrazek.jpg';
                                        $adapter = new Zend_File_Transfer_Adapter_Http();
                                        $adapter->addFilter('Rename', array('target'=>$destination, 'overwrite'=>true));
                                        $adapter->addValidator('Size', false, array('min' => 20, 'max' => 2000000));
                                        $adapter->addValidator('Count', false, array('min' =>1, 'max' => 1));
                                        $adapter->addValidator('IsImage', false, 'jpeg');
                                        if(!$adapter->isValid()) {
                            print_r($adapter->getMessages());
                                }
                                        try {
                        $adapter->receive();
                                } catch (Zend_File_Transfer_Exception $e) {
                                                $e->getMessage();
                                }

I get that error:
Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/usr/share/misc/magic) is not within the allowed path(s): (/home/wwday/:/tmp:/usr/local/lib/php/:/usr/sbin/:/usr/bin/:/usr/local/bin/:/usr/local/sbin/:/bin/:/sbin/) in /home/wwday/domains/wwday/wwdaypriv/library/Zend/Validate/File/MimeType.php on line 144
AND
Array ( [fileMimeTypeNotDetected] => )

What have I done wrong? I'm searchung all day, tyied many ways but i can't get it work :(
thomasW

Re: File upload problem:(

Reply Threaded More More options
Print post
Permalink
Look here for details to the openbase_dir directive:
http://php.net/manual/en/ini.sect.safe-mode.php

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

----- Original Message -----
From: "robos85" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, November 04, 2009 6:37 PM
Subject: [fw-general] File upload problem:(


>
> I have that code in my controller:
> $destination = PUBLIC_PATH.'/obrazek.jpg';
> $adapter = new Zend_File_Transfer_Adapter_Http();
> $adapter->addFilter('Rename', array('target'=>$destination,
> 'overwrite'=>true));
> $adapter->addValidator('Size', false, array('min' => 20, 'max' =>
> 2000000));
> $adapter->addValidator('Count', false, array('min' =>1, 'max' => 1));
> $adapter->addValidator('IsImage', false, 'jpeg');
> if(!$adapter->isValid()) {
>     print_r($adapter->getMessages());
>         }
> try {
>                 $adapter->receive();
>         } catch (Zend_File_Transfer_Exception $e) {
> $e->getMessage();
>         }
>
> I get that error:
> Warning: file_exists() [function.file-exists]: open_basedir restriction in
> effect. File(/usr/share/misc/magic) is not within the allowed path(s):
> (/home/wwday/:/tmp:/usr/local/lib/php/:/usr/sbin/:/usr/bin/:/usr/local/bin/:/usr/local/sbin/:/bin/:/sbin/)
> in
> /home/wwday/domains/wwday/wwdaypriv/library/Zend/Validate/File/MimeType.php
> on line 144
> AND
> Array ( [fileMimeTypeNotDetected] => )
>
> What have I done wrong? I'm searchung all day, tyied many ways but i can't
> get it work :(
> --
> View this message in context:
> http://old.nabble.com/File-upload-problem%3A%28-tp26201092p26201092.html
> Sent from the Zend Framework mailing list archive at Nabble.com.

robos85

Re: File upload problem:(

Reply Threaded More More options
Print post
Permalink
OK, that error is repaired, but $adapter->addValidator('IsImage', false, 'jpeg'); gets error: Array ( [fileMimeTypeNotDetected] => )

PHP logs give no errors. What can it be?
btw. is PHP 5.3 required for that operations?

thomasW wrote:
Look here for details to the openbase_dir directive:
http://php.net/manual/en/ini.sect.safe-mode.php

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

----- Original Message -----
From: "robos85" <robos85@gmail.com>
To: <fw-general@lists.zend.com>
Sent: Wednesday, November 04, 2009 6:37 PM
Subject: [fw-general] File upload problem:(


>
> I have that code in my controller:
> $destination = PUBLIC_PATH.'/obrazek.jpg';
> $adapter = new Zend_File_Transfer_Adapter_Http();
> $adapter->addFilter('Rename', array('target'=>$destination,
> 'overwrite'=>true));
> $adapter->addValidator('Size', false, array('min' => 20, 'max' =>
> 2000000));
> $adapter->addValidator('Count', false, array('min' =>1, 'max' => 1));
> $adapter->addValidator('IsImage', false, 'jpeg');
> if(!$adapter->isValid()) {
>     print_r($adapter->getMessages());
>         }
> try {
>                 $adapter->receive();
>         } catch (Zend_File_Transfer_Exception $e) {
> $e->getMessage();
>         }
>
> I get that error:
> Warning: file_exists() [function.file-exists]: open_basedir restriction in
> effect. File(/usr/share/misc/magic) is not within the allowed path(s):
> (/home/wwday/:/tmp:/usr/local/lib/php/:/usr/sbin/:/usr/bin/:/usr/local/bin/:/usr/local/sbin/:/bin/:/sbin/)
> in
> /home/wwday/domains/wwday/wwdaypriv/library/Zend/Validate/File/MimeType.php
> on line 144
> AND
> Array ( [fileMimeTypeNotDetected] => )
>
> What have I done wrong? I'm searchung all day, tyied many ways but i can't
> get it work :(
> --
> View this message in context:
> http://old.nabble.com/File-upload-problem%3A%28-tp26201092p26201092.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
thomasW

Re: File upload problem:(

Reply Threaded More More options
Print post
Permalink
You should not limit the IsImage valdator when using it.
When you need this then use the MimeType Validator.

Note that JPEG Pictures can have multiple mime variants and you limited to
only one. The mimetype is "image/jpeg" and not "jpeg"

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

----- Original Message -----
From: "robos85" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, November 04, 2009 9:13 PM
Subject: Re: [fw-general] File upload problem:(


>
> OK, that error is repaired, but $adapter->addValidator('IsImage', false,
> 'jpeg'); gets error: Array ( [fileMimeTypeNotDetected] => )
>
> PHP logs give no errors. What can it be?
>
> thomasW wrote:
>>
>> Look here for details to the openbase_dir directive:
>> http://php.net/manual/en/ini.sect.safe-mode.php
>>
>> Greetings
>> Thomas Weidner, I18N Team Leader, Zend Framework
>> http://www.thomasweidner.com
>>
>> ----- Original Message -----
>> From: "robos85" <[hidden email]>
>> To: <[hidden email]>
>> Sent: Wednesday, November 04, 2009 6:37 PM
>> Subject: [fw-general] File upload problem:(
>>
>>
>>>
>>> I have that code in my controller:
>>> $destination = PUBLIC_PATH.'/obrazek.jpg';
>>> $adapter = new Zend_File_Transfer_Adapter_Http();
>>> $adapter->addFilter('Rename', array('target'=>$destination,
>>> 'overwrite'=>true));
>>> $adapter->addValidator('Size', false, array('min' => 20, 'max' =>
>>> 2000000));
>>> $adapter->addValidator('Count', false, array('min' =>1, 'max' => 1));
>>> $adapter->addValidator('IsImage', false, 'jpeg');
>>> if(!$adapter->isValid()) {
>>>     print_r($adapter->getMessages());
>>>         }
>>> try {
>>>                 $adapter->receive();
>>>         } catch (Zend_File_Transfer_Exception $e) {
>>> $e->getMessage();
>>>         }
>>>
>>> I get that error:
>>> Warning: file_exists() [function.file-exists]: open_basedir restriction
>>> in
>>> effect. File(/usr/share/misc/magic) is not within the allowed path(s):
>>> (/home/wwday/:/tmp:/usr/local/lib/php/:/usr/sbin/:/usr/bin/:/usr/local/bin/:/usr/local/sbin/:/bin/:/sbin/)
>>> in
>>> /home/wwday/domains/wwday/wwdaypriv/library/Zend/Validate/File/MimeType.php
>>> on line 144
>>> AND
>>> Array ( [fileMimeTypeNotDetected] => )
>>>
>>> What have I done wrong? I'm searchung all day, tyied many ways but i
>>> can't
>>> get it work :(
>>> --
>>> View this message in context:
>>> http://old.nabble.com/File-upload-problem%3A%28-tp26201092p26201092.html
>>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>
>>
>>
>
> --
> View this message in context:
> http://old.nabble.com/File-upload-problem%3A%28-tp26201092p26203838.html
> Sent from the Zend Framework mailing list archive at Nabble.com.

robos85

Re: File upload problem:(

Reply Threaded More More options
Print post
Permalink
OK i used
$adapter->addValidator('MimeType', false, array('image/jpeg'));
and now I get:
Array ( [fileMimeTypeNotDetected] => The mimetype of file 'dsc00160e.jpg' could not been detected )

I want to restrict only .jpg

Is php5.3 or special modules required?
thomasW wrote:
You should not limit the IsImage valdator when using it.
When you need this then use the MimeType Validator.

Note that JPEG Pictures can have multiple mime variants and you limited to
only one. The mimetype is "image/jpeg" and not "jpeg"

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

----- Original Message -----
From: "robos85" <robos85@gmail.com>
To: <fw-general@lists.zend.com>
Sent: Wednesday, November 04, 2009 9:13 PM
Subject: Re: [fw-general] File upload problem:(


>
> OK, that error is repaired, but $adapter->addValidator('IsImage', false,
> 'jpeg'); gets error: Array ( [fileMimeTypeNotDetected] => )
>
> PHP logs give no errors. What can it be?
>
> thomasW wrote:
>>
>> Look here for details to the openbase_dir directive:
>> http://php.net/manual/en/ini.sect.safe-mode.php
>>
>> Greetings
>> Thomas Weidner, I18N Team Leader, Zend Framework
>> http://www.thomasweidner.com
>>
>> ----- Original Message -----
>> From: "robos85" <robos85@gmail.com>
>> To: <fw-general@lists.zend.com>
>> Sent: Wednesday, November 04, 2009 6:37 PM
>> Subject: [fw-general] File upload problem:(
>>
>>
>>>
>>> I have that code in my controller:
>>> $destination = PUBLIC_PATH.'/obrazek.jpg';
>>> $adapter = new Zend_File_Transfer_Adapter_Http();
>>> $adapter->addFilter('Rename', array('target'=>$destination,
>>> 'overwrite'=>true));
>>> $adapter->addValidator('Size', false, array('min' => 20, 'max' =>
>>> 2000000));
>>> $adapter->addValidator('Count', false, array('min' =>1, 'max' => 1));
>>> $adapter->addValidator('IsImage', false, 'jpeg');
>>> if(!$adapter->isValid()) {
>>>     print_r($adapter->getMessages());
>>>         }
>>> try {
>>>                 $adapter->receive();
>>>         } catch (Zend_File_Transfer_Exception $e) {
>>> $e->getMessage();
>>>         }
>>>
>>> I get that error:
>>> Warning: file_exists() [function.file-exists]: open_basedir restriction
>>> in
>>> effect. File(/usr/share/misc/magic) is not within the allowed path(s):
>>> (/home/wwday/:/tmp:/usr/local/lib/php/:/usr/sbin/:/usr/bin/:/usr/local/bin/:/usr/local/sbin/:/bin/:/sbin/)
>>> in
>>> /home/wwday/domains/wwday/wwdaypriv/library/Zend/Validate/File/MimeType.php
>>> on line 144
>>> AND
>>> Array ( [fileMimeTypeNotDetected] => )
>>>
>>> What have I done wrong? I'm searchung all day, tyied many ways but i
>>> can't
>>> get it work :(
>>> --
>>> View this message in context:
>>> http://old.nabble.com/File-upload-problem%3A%28-tp26201092p26201092.html
>>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>
>>
>>
>
> --
> View this message in context:
> http://old.nabble.com/File-upload-problem%3A%28-tp26201092p26203838.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
thomasW

Re: File upload problem:(

Reply Threaded More More options
Print post
Permalink
When you want to limit to *.jpg use the Extension validator.
When you want to limit to JPEG files (regardless of the extension), then you
must have
* FileInfo extension or
* MimeType extension installed

When you want it the unsave way then you can switch on HTTP detection.

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

----- Original Message -----
From: "robos85" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, November 04, 2009 9:29 PM
Subject: Re: [fw-general] File upload problem:(


>
> OK i used
> $adapter->addValidator('MimeType', false, array('image/jpeg'));
> and now I get:
> Array ( [fileMimeTypeNotDetected] => The mimetype of file 'dsc00160e.jpg'
> could not been detected )
>
> I want to restrict only .jpg
>
> Is php5.3 or special modules required?
>
> thomasW wrote:
>>
>> You should not limit the IsImage valdator when using it.
>> When you need this then use the MimeType Validator.
>>
>> Note that JPEG Pictures can have multiple mime variants and you limited
>> to
>> only one. The mimetype is "image/jpeg" and not "jpeg"
>>
>> Greetings
>> Thomas Weidner, I18N Team Leader, Zend Framework
>> http://www.thomasweidner.com
>>
>> ----- Original Message -----
>> From: "robos85" <[hidden email]>
>> To: <[hidden email]>
>> Sent: Wednesday, November 04, 2009 9:13 PM
>> Subject: Re: [fw-general] File upload problem:(
>>
>>
>>>
>>> OK, that error is repaired, but $adapter->addValidator('IsImage', false,
>>> 'jpeg'); gets error: Array ( [fileMimeTypeNotDetected] => )
>>>
>>> PHP logs give no errors. What can it be?
>>>
>>> thomasW wrote:
>>>>
>>>> Look here for details to the openbase_dir directive:
>>>> http://php.net/manual/en/ini.sect.safe-mode.php
>>>>
>>>> Greetings
>>>> Thomas Weidner, I18N Team Leader, Zend Framework
>>>> http://www.thomasweidner.com
>>>>
>>>> ----- Original Message -----
>>>> From: "robos85" <[hidden email]>
>>>> To: <[hidden email]>
>>>> Sent: Wednesday, November 04, 2009 6:37 PM
>>>> Subject: [fw-general] File upload problem:(
>>>>
>>>>
>>>>>
>>>>> I have that code in my controller:
>>>>> $destination = PUBLIC_PATH.'/obrazek.jpg';
>>>>> $adapter = new Zend_File_Transfer_Adapter_Http();
>>>>> $adapter->addFilter('Rename', array('target'=>$destination,
>>>>> 'overwrite'=>true));
>>>>> $adapter->addValidator('Size', false, array('min' => 20, 'max' =>
>>>>> 2000000));
>>>>> $adapter->addValidator('Count', false, array('min' =>1, 'max' => 1));
>>>>> $adapter->addValidator('IsImage', false, 'jpeg');
>>>>> if(!$adapter->isValid()) {
>>>>>     print_r($adapter->getMessages());
>>>>>         }
>>>>> try {
>>>>>                 $adapter->receive();
>>>>>         } catch (Zend_File_Transfer_Exception $e) {
>>>>> $e->getMessage();
>>>>>         }
>>>>>
>>>>> I get that error:
>>>>> Warning: file_exists() [function.file-exists]: open_basedir
>>>>> restriction
>>>>> in
>>>>> effect. File(/usr/share/misc/magic) is not within the allowed path(s):
>>>>> (/home/wwday/:/tmp:/usr/local/lib/php/:/usr/sbin/:/usr/bin/:/usr/local/bin/:/usr/local/sbin/:/bin/:/sbin/)
>>>>> in
>>>>> /home/wwday/domains/wwday/wwdaypriv/library/Zend/Validate/File/MimeType.php
>>>>> on line 144
>>>>> AND
>>>>> Array ( [fileMimeTypeNotDetected] => )
>>>>>
>>>>> What have I done wrong? I'm searchung all day, tyied many ways but i
>>>>> can't
>>>>> get it work :(
>>>>> --
>>>>> View this message in context:
>>>>> http://old.nabble.com/File-upload-problem%3A%28-tp26201092p26201092.html
>>>>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/File-upload-problem%3A%28-tp26201092p26203838.html
>>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>
>>
>>
>
> --
> View this message in context:
> http://old.nabble.com/File-upload-problem%3A%28-tp26201092p26204073.html
> Sent from the Zend Framework mailing list archive at Nabble.com.

robos85

Re: File upload problem:(

Reply Threaded More More options
Print post
Permalink
Thanks for advice :)
I want only jpg available.
thomasW wrote:
When you want to limit to *.jpg use the Extension validator.
When you want to limit to JPEG files (regardless of the extension), then you
must have
* FileInfo extension or
* MimeType extension installed

When you want it the unsave way then you can switch on HTTP detection.

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

----- Original Message -----
From: "robos85" <robos85@gmail.com>
To: <fw-general@lists.zend.com>
Sent: Wednesday, November 04, 2009 9:29 PM
Subject: Re: [fw-general] File upload problem:(


>
> OK i used
> $adapter->addValidator('MimeType', false, array('image/jpeg'));
> and now I get:
> Array ( [fileMimeTypeNotDetected] => The mimetype of file 'dsc00160e.jpg'
> could not been detected )
>
> I want to restrict only .jpg
>
> Is php5.3 or special modules required?
>
> thomasW wrote:
>>
>> You should not limit the IsImage valdator when using it.
>> When you need this then use the MimeType Validator.
>>
>> Note that JPEG Pictures can have multiple mime variants and you limited
>> to
>> only one. The mimetype is "image/jpeg" and not "jpeg"
>>
>> Greetings
>> Thomas Weidner, I18N Team Leader, Zend Framework
>> http://www.thomasweidner.com
>>
>> ----- Original Message -----
>> From: "robos85" <robos85@gmail.com>
>> To: <fw-general@lists.zend.com>
>> Sent: Wednesday, November 04, 2009 9:13 PM
>> Subject: Re: [fw-general] File upload problem:(
>>
>>
>>>
>>> OK, that error is repaired, but $adapter->addValidator('IsImage', false,
>>> 'jpeg'); gets error: Array ( [fileMimeTypeNotDetected] => )
>>>
>>> PHP logs give no errors. What can it be?
>>>
>>> thomasW wrote:
>>>>
>>>> Look here for details to the openbase_dir directive:
>>>> http://php.net/manual/en/ini.sect.safe-mode.php
>>>>
>>>> Greetings
>>>> Thomas Weidner, I18N Team Leader, Zend Framework
>>>> http://www.thomasweidner.com
>>>>
>>>> ----- Original Message -----
>>>> From: "robos85" <robos85@gmail.com>
>>>> To: <fw-general@lists.zend.com>
>>>> Sent: Wednesday, November 04, 2009 6:37 PM
>>>> Subject: [fw-general] File upload problem:(
>>>>
>>>>
>>>>>
>>>>> I have that code in my controller:
>>>>> $destination = PUBLIC_PATH.'/obrazek.jpg';
>>>>> $adapter = new Zend_File_Transfer_Adapter_Http();
>>>>> $adapter->addFilter('Rename', array('target'=>$destination,
>>>>> 'overwrite'=>true));
>>>>> $adapter->addValidator('Size', false, array('min' => 20, 'max' =>
>>>>> 2000000));
>>>>> $adapter->addValidator('Count', false, array('min' =>1, 'max' => 1));
>>>>> $adapter->addValidator('IsImage', false, 'jpeg');
>>>>> if(!$adapter->isValid()) {
>>>>>     print_r($adapter->getMessages());
>>>>>         }
>>>>> try {
>>>>>                 $adapter->receive();
>>>>>         } catch (Zend_File_Transfer_Exception $e) {
>>>>> $e->getMessage();
>>>>>         }
>>>>>
>>>>> I get that error:
>>>>> Warning: file_exists() [function.file-exists]: open_basedir
>>>>> restriction
>>>>> in
>>>>> effect. File(/usr/share/misc/magic) is not within the allowed path(s):
>>>>> (/home/wwday/:/tmp:/usr/local/lib/php/:/usr/sbin/:/usr/bin/:/usr/local/bin/:/usr/local/sbin/:/bin/:/sbin/)
>>>>> in
>>>>> /home/wwday/domains/wwday/wwdaypriv/library/Zend/Validate/File/MimeType.php
>>>>> on line 144
>>>>> AND
>>>>> Array ( [fileMimeTypeNotDetected] => )
>>>>>
>>>>> What have I done wrong? I'm searchung all day, tyied many ways but i
>>>>> can't
>>>>> get it work :(
>>>>> --
>>>>> View this message in context:
>>>>> http://old.nabble.com/File-upload-problem%3A%28-tp26201092p26201092.html
>>>>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/File-upload-problem%3A%28-tp26201092p26203838.html
>>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>
>>
>>
>
> --
> View this message in context:
> http://old.nabble.com/File-upload-problem%3A%28-tp26201092p26204073.html
> Sent from the Zend Framework mailing list archive at Nabble.com.