您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

在symfony2下转移本地文件夹

2025/12/19 12:36:42发布34次查看
我处理一个excel文件. 因为有8000多行, 所以我先上传到temp文件夹里,用ajax分批处理. 全部处理后转移到别的文件夹里.
upload到temp操作.
public function fileuploadaction() { $content = $this->getrequest()->files->get('file0'); //to get file object $filename = $content->getclientoriginalname(); $file_ext = $content->getclientoriginalextension(); $content->move( $this->get('kernel')->getrootdir() . '/../web/temp/', $filename ); $path = $this->get('kernel')->getrootdir() . '/../web/temp/' . $filename; $return = $this->saveaolsurvey($path, 0); return new response($return);}

全部处理完毕后
$content = new file($path,true); //$path 是临时文件夹temp里的地址 $filename = $content->getfilename(); $date = date('ymd'); $content->move( $this->get('kernel')->getrootdir() . '/../web/'.$date.'/', $filename ); unlink($path);

移动后删除临时文件夹里的文件。
但是却出现了如下的错误信息。
exception thrown when handling an exception (symfony\component\httpkernel\exception\flattenexception: warning: json_encode() [function.json-encode]: invalid utf-8 sequence in argument in c:\wamp\www***\app\cache\dev\classes.php line 342)
上传时是使用uploadedfile , new的是file.
文件名并没有改变.
请各位大侠帮我解惑
=========================================================
我现在暂时用rename来更换了地址.
回复内容: 我处理一个excel文件. 因为有8000多行, 所以我先上传到temp文件夹里,用ajax分批处理. 全部处理后转移到别的文件夹里.
upload到temp操作.
public function fileuploadaction() { $content = $this->getrequest()->files->get('file0'); //to get file object $filename = $content->getclientoriginalname(); $file_ext = $content->getclientoriginalextension(); $content->move( $this->get('kernel')->getrootdir() . '/../web/temp/', $filename ); $path = $this->get('kernel')->getrootdir() . '/../web/temp/' . $filename; $return = $this->saveaolsurvey($path, 0); return new response($return);}

全部处理完毕后
$content = new file($path,true); //$path 是临时文件夹temp里的地址 $filename = $content->getfilename(); $date = date('ymd'); $content->move( $this->get('kernel')->getrootdir() . '/../web/'.$date.'/', $filename ); unlink($path);

移动后删除临时文件夹里的文件。
但是却出现了如下的错误信息。
exception thrown when handling an exception (symfony\component\httpkernel\exception\flattenexception: warning: json_encode() [function.json-encode]: invalid utf-8 sequence in argument in c:\wamp\www***\app\cache\dev\classes.php line 342)
上传时是使用uploadedfile , new的是file.
文件名并没有改变.
请各位大侠帮我解惑
=========================================================
我现在暂时用rename来更换了地址.
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product