Transfer a local folder under symfony2

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.