zf Zend_File_Transfer_Adapter_Http 上传文件 File was illegally uploaded. This could be a possi

4 篇文章 0 订阅
1 篇文章 0 订阅

zf 开发用 Zend_File_Transfer_Adapter_Http();上传一个文件,出现以下错误

file upload error: Array ( [fileUploadErrorAttack] => File 'avatar' was illegally uploaded. This could be a possible attack )

百思不得其解

 

留意到有人也遇到这个问题,说法如下:

I also had this problem (fileUploadErrorAttack) with multi file upload (without Zend_Form) and was able to solve it for my setup:

$upload = new Zend_File_Transfer_Adapter_Http();

If you call
$upload->receive();
in your code you have to know that receive() renames all TMP files, regardless if
$upload->addFilter('Rename', .....
is defined!
For files withour rename filter it renames the file within the /tmp folder to whatever
$upload->getFileName(...
delivers for that file, which is the name sent by the browser (file name on the user's disk).

So I think there are two ways to get it right:
1) with $upload->receive(); handle all files at once (e.g. with a rename filter set for all files)
2) $upload->receive($fieldName); call seperately for each file (== name field in the form) in a loop

I think receive() without parameter "removes" everything from $_FILES[] (so to say); that's why the error appears as it does.

 

第二种说法:

  called $form->getValue('uploadfile') first.
after run upper code uploaded file(not tmp file) has been created in tmp directory.

我的问题为第二种说法,在windows/temp文件夹下看到过文件,但一直无法上传,于是修改代码

//$blogData = $formPhotoBlog->getValues();
       
       //上传和获取图片信息
       $adapter = new Zend_File_Transfer_Adapter_Http();
       $path = PUBLIC_PATH.'\photos';//date("Y-m").'/avatar/';
       $fileInfo = $adapter->getFileInfo();//获取基本文件信息

注释了一句,问题解决了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值