FIle upload from a rest client to a rest server

后端 未结 5 969
长发绾君心
长发绾君心 2021-02-09 07:01

I created a rest server using the codeigniter rest server library created by PhilSturgeon :

github.com/philsturgeon/codeigniter-restserver

Now, I am using Codei

5条回答
  •  悲&欢浪女
    2021-02-09 07:34

    As Amit has suggested, you can send the contents of a file file_get_contents('foo.jpg') or you could do something more true to the spec and do something like:

    POST /images

    Content-Type: image/jpeg

    Then for the body you just set the contents of the image (or whatever type of file you're firing off).

    You can then pick that up in your PHP with:

    file_get_contents('php://input');
    

    That will have the contents of your image, so you can save it wherever.

提交回复
热议问题