In PHP, the method for uploading files through POST request is as follows:
Function send_file ($ URL, $ post = '', $ file ='') {$ EOL = "\ r \ n"; $ mime_boundary = MD5 (Time ()); $ DATA = ''; $ confirmation =''; date_default_timezone_set ("Asia/Shanghai"); $ time = date ("Y-m-d h: I: s "); $ post ["FILENAME"] = $ file [filename]; foreach ($ post as $ key => $ value) {$ data. = '--'. $ mime_boundary. $ EOL; $ data. = 'content-Disposition: Form-data; '; $ data. = "name = ". $ key. $ EOL. $ EOL; $ data. = $ value. $ EOL;} $ data. = '--'. $ mime_boundary. $ EOL; $ data. = 'content-Disposition: Form-data; name = '. $ file [name]. '; filename = '. $ file [filename]. $ EOL; $ data. = 'content-type: text/plain '. $ EOL; $ data. = 'content-transfer-encoding: Binary '. $ EOL. $ EOL; $ data. = $ file [filedata]. $ EOL; $ data. = "--". $ mime_boundary. "--". $ EOL. $ EOL; $ Params = array ('http' => array ('method' => 'post', 'header' => 'content-type: multipart/form-data; boundary = '. $ mime_boundary. $ EOL, 'content' => $ data); $ CTX = stream_context_create ($ Params); $ response = file_get_contents ($ URL, file_text, $ CTX ); return $ response ;}