I am processing an excel file. because there are more than 8000 rows, I first uploaded them to the temp folder and processed them in batches using ajax. after processing all the data, move it to another folder. upload to temp operation. {code ...} {code ...} move and delete files in the Temporary Folder. But... I am processing an excel file. Because there are more than 8000 lines, I first upload it to the temp folder and use ajax for batch processing. All the processing is then transferred to another folder.
Upload to temp operation.
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);}
After all processing is completed
$ Content = new File ($ path, true); // $ path is the address in the temp Temporary Folder $ filename = $ content-> getFilename (); $ date = date ('ymmd'); $ content-> move ($ this-> get ('kernel ')-> getRootDir (). '/.. /web /'. $ date. '/', $ filename); unlink ($ path );
Move and delete files in the Temporary Folder.
However, the following error message is displayed.
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)
The uploadedFile is used for upload, and the new file is used for upload.
The file name has not changed.
Thank you!
========================================================== ========================
I have used rename to change the address.
Reply content:
I processed an excel file. Because there are more than 8000 rows, I first uploaded the file to the temp folder and processed it in batches Using ajax. All the processed files were transferred to another folder.
Upload to temp operation.
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);}
After all processing is completed
$ Content = new File ($ path, true); // $ path is the address in the temp Temporary Folder $ filename = $ content-> getFilename (); $ date = date ('ymmd'); $ content-> move ($ this-> get ('kernel ')-> getRootDir (). '/.. /web /'. $ date. '/', $ filename); unlink ($ path );
Move and delete files in the Temporary Folder.
However, the following error message is displayed.
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)
The uploadedFile is used for upload, and the new file is used for upload.
The file name has not changed.
Thank you!
========================================================== ========================
I have used rename to change the address.