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来更换了地址.
