(CURL, PHP) Uploading files with PUT request, How do I process this?

后端 未结 2 836
执笔经年
执笔经年 2021-01-21 23:51

this is what i have in process.php

parse_str(file_get_contents(\"php://input\"),$upload_data);
if (isset($upload_data)) {
   print_r($upload_data);
   exit;
}
         


        
2条回答
  •  旧时难觅i
    2021-01-21 23:56

    Short answer

    The only way in your situation is to parse raw request manually (look at this gist)

    Thoughts

    • PUT request could be used to upload one file only (not from html upload form, but using custom request). On the server you just get raw file content and writes it into some file.
    • Use PUT without files (application/x-www-form-urlencoded) and parse raw request using parse_str(file_get_contents("php://input"), $_PUT);
    • Use POST to upload files (multipart/form-data).

提交回复
热议问题