Angularjs-how can I use angular's $ http to submit a form (including the File type), which can be obtained using the $ _ FILES variable in backend php?

Source: Internet
Author: User
I want to upload a file by selecting a zip file and passing it to the background php file through ajax. the php file can be obtained using $ _ FILES, but I don't know how to implement it. Although the ghost file is... I want to upload a file by selecting a zip file and passing it to the background php file via ajax. the php file can be obtained using $ _ FILES, but I don't know how to implement it.

I tried to save the zip file by using the following method instead of $ _ FILES.

$input = file_get_contents("php://input",true);file_put_contents('temp/olin.zip',$input);

However, although the resource manager can open the stored olin.zip file normally, there is a problem with the php zip operation. zip_read and close errors will be reported. (The zip file generated by the above two codes can be operated normally)

Ask how to read $ _ FILES, or use php: // input to generate a normal zip file.

Reply content:

I want to upload a file by selecting a zip file and passing it to the background php file through ajax. the php file can be obtained using $ _ FILES, but I don't know how to implement it.

I tried to save the zip file by using the following method instead of $ _ FILES.

$input = file_get_contents("php://input",true);file_put_contents('temp/olin.zip',$input);

However, although the resource manager can open the stored olin.zip file normally, there is a problem with the php zip operation. zip_read and close errors will be reported. (The zip file generated by the above two codes can be operated normally)

Ask how to read $ _ FILES, or use php: // input to generate a normal zip file.

$ Http provided by angularjs cannot be uploaded.
I tried it for a long time. later I used native xhr to succeed. you can refer to the upload instructions in this article.

Angular file Upload command

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.