See at http://www.thomasweidner.com examplecode.
Editing the $_FILES array can lead to an attacker exception. I would not do
this as it's unsecure.
Related to your second example:
You should set the options like described in the manual:
$upload->addFilter('Rename', array('target' => 'image_'
.$userid.'.'.$ext[‘extension’], true));
Note the missing arraykey in your example.
Also you can omit the source when you are only working with one uploaded
file.
The manual does also describe the things above.
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com
----- Original Message -----
From: "Ehask71" <[email protected]>
To: <[email protected]>
Sent: Wednesday, February 04, 2009 3:17 AM
Subject: [fw-general] Zend_File_Transfer_Adapter_Http() Rename Filter issue
I have tried and tried to get this Rename filter to work to no avail
My workaround if it helps anyone was to intercept and modify the $_FILES
array before making the call to
Zend_File_Transfer_Adapter_Http()
if($form->isValid($_POST)) {
if(isset($_FILES['file1'])){
$ext = pathinfo($_FILES['file1']['name']);
$_FILES['file1']['name'] = 'image_' .
$userid.'.'.$ext[‘extension’];
}
$upload = new Zend_File_Transfer_Adapter_Http();
This worked. However this didn’t:
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->addValidator('Size', false, 200000, 'file1');
$upload->setDestination('/home/uglymen/public_html/tlp/tmp/');
$files = $upload->getFileInfo();
foreach ($files as $file => $info) {
if($upload->isValid($file)){
$ext = pathinfo($info[‘name’]);
$upload->addFilter('Rename', array($info['name'],'image_' .
$userid.'.'.$ext[‘extension’], true));
$upload->receive($file);
Does anyone have a working example of how to rename a file using the filter?
For large sites it is a necessity.
Thx for any pointers
Eric Haskins
--
View this message in context:
http://www.nabble.com/Zend_File_Transfer_Adapter_Http%28%29-Rename-Filter-issue-tp21823191p21823191.html
Sent from the Zend Framework mailing list archive at Nabble.com.