2009年9月2日星期三

Re: [fw-mvc] Change name of file transfer

I don't expect that "rand().jpg" exists as uploaded file.
According to the methods API the third parameter is described as "Files to
limit this filter to"
I would use the options of the rename filter to rename a file.

Also I don't think that the rename filter accepts a string as array.
The examples in the manual are always using array notation for the second
parameter.

Additionally, manipulating the $files array could lead to a "attacker"
exception in some cases.
Be aware of possible side-problems using this approach.

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

----- Original Message -----
From: "Juan Pablo Marroni" <jmarroni@gmail.com>
To: <fw-mvc@lists.zend.com>
Sent: Thursday, September 03, 2009 4:39 AM
Subject: [fw-mvc] Change name of file transfer


> Hi All,
> I have a problem when I want to change the name of all the images. When I
> upload them with Zend_File_Transfer_Adapter_Http I get an error.
> Here is the code and the error:
>
> The code
> foreach ($files as $file => $info) {
> if($upload->isValid($file)){
> $files['picture']['name'][$count] =
> $files[$file]['name'];
> $count ++;
> $upload->addFilter('Rename',
> ROOT_DIR.ROOT_IMAGE_UPLOAD,
> rand().'.jpg');
> if ($upload->receive($file)){
> print_r($upload->getMessages());
> }
> }
> }
>
> The error
> *Warning*: array_search()
> [function.array-search<http://www.bubblyapp.com/submit/function.array-search>]:
> Wrong datatype for second argument in*
> .../Zend/File/Transfer/Adapter/Http.php* on line *164*
>
> Thank's.
>

没有评论: