Ask the app to upload images, how PHP receives processing (TP)

Source: Internet
Author: User
A lot of information on the Internet,
Some use Base64.
some use $_files;
($_post;
file_get_contents (' Php://input ')

Is there an example of a client upload that can be emulated and then a PHP backend processing done?
I don't understand the principle, thank you.


Reply to discussion (solution)

With the TP itself with the upload class, no? Change to interface

Class Useraction extends action{//add Public function Add () {//Var_dump (Uniqid (). (                        Time (). Rand (0,100));//Die (); Import (' ORG.Net.UploadFile '); $upload = new UploadFile ();//Instantiate upload class $upload->maxsize = 3145728;//Set attachment upload size $upload->allowex ts = array (' jpg ', ' gif ', ' PNG ', ' jpeg ');//Set attachment upload type//$upload->saverule = uniqid;//This is to change the name of the image, you can change the name of more than one picture,            To achieve the different names of the picture so that there will be no coverage of the phenomenon $upload->saverule= ' mytime ';                $upload->savepath = './public/uploads/';//Set Attachments upload directory if (! $upload->upload ()) {//Upload error message            $this->error ($upload->geterrormsg ());            }else{//Upload successfully uploaded file information $info = $upload->getuploadfileinfo ();            } $user = M (' user '); $user->create (); Create a data object $user->user_pic = "http://". $this->_server (' Http_host '). ' /public/uploads/'. $info [0][' Savename ']; Save uploaded photos Assemble yourself as needed $user->user_idcard = "http://". $this->_server (' Http_host '). '            /public/uploads/'. $info [1][' Savename ']; $user->user_card = "http://" $this->_server (' Http_host '). '            /public/uploads/'. $info [2][' Savename ']; $user->piclink = "http://" $this->_server (' Http_host '). ' /public/uploads/'. $info [0][' Savename '];            $user->time = Date (' y-m-d h:i:s ', Time ());            $user->add ();            echo $flash->getlastsql ();            Die (); $this->success ("Data saved successfully!  "); }

How to test, must be submitted with the client? So we can simulate the data? Thank you

Our app uploads images using HTTP upload, I test when using the form form, set the form property to Enctype= "Multipart/form-data"
Background access can be obtained with $_files.



How to look at the app front-end upload pictures with what format ah? Ask

Then you have to ask people who develop the app how to upload images, usually http form upload, that is, you use form formYou can simulate the app upload
Of course, you can also, print out the data inside the $_files, if there is, it means to get the app upload pictures, did not fail Bai

App upload, PHP this side receive not change, and Web page upload the same.
Use the Content-disposition:form-data app over there; This way you can upload it.
Reference: http://blog.csdn.net/fdipzone/article/details/12180523

Depending on how the app is uploaded, the PHP-side access is determined, most of which are form-based uploads.
$_files; file_get_contents (' Php://input ') is available.

There are some first read the contents of the file in the client, then Base64 encoding, and then upload.
Relatively simple large file breakpoint upload, in fact, you can this "mainly by app processing."

  • 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.