Hi latterd,

my plan is to write the file directly to the server from an external URL
(not from the user upload).
For example
copy('https://alphalister.com/files/cmple_35e2/i/m/e0d215f9a9f0399f2f0dff192ed0ffba.jpg',
'/server/files/location/e0d215f9a9f0399f2f0dff192ed0ffba.jpg');
Then be able to use the existing zf validators on that new file (if failed
validation delete it) all of this will be done on the backend.

Whenever I try to use the zf validator independently of the zf-form upload,
it always returns false.

$validator = new Validator\Extension(array(
                                'extension' => explode(',', 
$this->config->valid_upload_types),
                                'messages' => array(
                                        'fileExtensionFalse' => 'Invalid 
picture type'
                        )));
$isValid = $validator->isValid();


I can't figure out a way to inject actual file names into the validator...
For example:

$isValid =
$validator->isValid(array('/server/files/location/e0d215f9a9f0399f2f0dff192ed0ffba.jpg'));

this also returns false

Thank You!!
Roman.


latterd wrote
> Hi,
> 
> My assumption is that you want to upload a file, perform validation on it,
> then upload to another server?
> 
> So the first step is to get the file, via the validators you mentioned.
> 
> After that you have the file on disk, validated.
> 
> Now all that is left to do is put/upload/copy/post the file to the server
> you want.
> 
> Does that help :)
> 
> 
> 
> 
> On 26 May 2015 at 21:09, cmple <

> roman.vidyayev@

> > wrote:
> 
>> Hi latterd,
>> for my existing image upload validation I'm using multiple zf validators
>> with custom error messages:
>>
>> array('Extension', true, array(
>>         'extension' => explode(',', $this->config->valid_upload_types),
>>         'messages' => array(
>>                 'fileExtensionFalse' => 'Invalid picture type'
>>         )
>> )),
>> array('IsImage', true, array(
>>         'magicFile' => false,
>> )),
>> array('Size', true, array(
>>         'max' => $this->config->max_upload_size,
>>         'messages' => array(
>>                 'fileSizeTooBig' => 'Picture size is too big'
>>         ),
>> )),
>> array('ImageSize', true,
>>         array(
>>                 'minwidth' => $minSize->minwidth,
>>                 'minheight' => $minSize->minheight,
>>                 'maxwidth' => $this->config->max_width,
>>                 'maxheight' => $this->config->max_height,
>>                 'messages' => array(
>>                         'fileImageSizeHeightTooBig' => 'Picture height is
>> too big',
>>                         'fileImageSizeWidthTooBig' => 'Picture width is
>> too big',
>>                 ),
>>         ),
>> ),
>>
>> are you suggesting that there is no way around this but only to create
>> custom validations such as the use of the getimagesize() function?
>>
>> also is it possible to use getimagesize() before uploading the image to
>> the
>> server (even to the /tmp folder)?
>>
>> Thank You!
>> Roman.
>>
>>
>>
>> latterd wrote
>> > Hi,
>> >
>> > You can find out file information using:
>> > http://php.net/manual/en/function.finfo-file.php
>> >
>> > Also, a common way is to use getimagesize() function, if it throws an
>> > error
>> > or returns false its not an image.
>> >
>> > I think it is a 2 step process, first you get the image from the url,
>> > validate etc.
>> >
>> > Then upload/send to your server.
>> >
>> >
>> >
>> > On 26 May 2015 at 17:05, cmple <
>>
>> > roman.vidyayev@
>>
>> > > wrote:
>> >
>> >> Hey Alejandro,
>> >> Thanks for your reply!
>> >> I have one more question, how can I apply the file Validation without
>> >> using
>> >> the global $_FILES[] variable?
>> >>
>> >> for example:
>> >> $validator = new Validator\IsImage();
>> >> $valid = $validator->isValid();
>> >>
>> >> Thanks!
>> >> Roman.
>> >>
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://zend-framework-community.634137.n4.nabble.com/ZF2-Import-and-validate-external-pictures-from-URLs-tp4662542p4662545.html
>> >> Sent from the Zend Framework mailing list archive at Nabble.com.
>> >>
>> >> --
>> >> List:
>>
>> > [email protected]
>>
>> >> Info: http://framework.zend.com/archives
>> >> Unsubscribe:
>>
>> > [email protected]
>>
>> >>
>> >>
>> >>
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://zend-framework-community.634137.n4.nabble.com/ZF2-Import-and-validate-external-pictures-from-URLs-tp4662542p4662547.html
>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>
>> --
>> List: 

> [email protected]

>> Info: http://framework.zend.com/archives
>> Unsubscribe: 

> [email protected]

>>
>>
>>





--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Import-and-validate-external-pictures-from-URLs-tp4662542p4662550.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to