æ¾è©ï¼³ï¼¡ï¼´ï¼¯ï¼¸ãããæè¿ããããã¯ã¼ã¯é¢é£ã®åå¼·ããã¦ããã¾ãã¦ãã¢ããªã±ã¼ã·ã§ã³ããPHPãå©ãããããããã¦ãã¾ãã
ãªã¢ã¼ãããã·ã¼ã¸ã£çã«ãã«ããã¼ããã©ã¼ã ãã¼ã¿ã§ä»»æã®ã³ãã³ãããã¤ããªãã¡ã¤ã«ãéã£ãããªããããã®ã§ãããSocketãç´ã«ä½¿ã£ã¦ãããããã®ã§HTTPã®ãããã³ã«ã使ã£ã¦éä¿¡ããªãã¨ããã¾ããã
éä¿¡å¨ãã«è©³ããæ¹ã«ã¨ã£ã¦ã¯ãä»æ´ãããªãã¨â¦â¦ããªãã¦è¨ããã¦ãã¾ããããªãã®ã§ãããèªåã®ããã«ããã«ããã¼ããã©ã¼ã ãã¼ã¿ã使ãéã®éä¿¡å
容ã«ã¤ãã¦ãè¦ãæ¸ãã¨ãã¦æ¸ãã¦ãããã¨æã£ã次第ã§ãã
ã¡ãªã¿ã«ããã«ããã¼ããã©ã¼ã ãã¼ã¿ã¨ã¯ãHTTPã®ãªã¯ã¨ã¹ãã§è¤æ°ã®ãã©ã¼ã ãã¼ã¿(ãã«ããã¼ã)ãéãããã®å½¢å¼(HTTPã®ãããã³ã«)ã§ãã誰ã§ããã使ã£ã¦ãããã®ã§ããã©ã¦ã¶ã§ãããã¼ã¸ãéãã¦ãååã®å
¥åï¼ç»åãã¡ã¤ã«ã®ã¢ãããã¼ãããªãã¦ã¨ãã«ä½¿ããã¦ãã¾ãã
ã
â HTTPãããé¨
ã³ã³ãã³ãã¿ã¤ãã«ä»¥ä¸ãæå®ãã¾ããContent-Type: multipart/form-data; boundary=ããã¦ã³ããªæååã\r\n
ãã¦ã³ããªæååã¨ã¯ãè¤æ°ã®æ
å ±ãç¶ãã¦éãéã®æ
å ±å士ã®ãä»åç·ãã®å½¹ç®ãæããã¾ãããã®æåã調ã¹ã¦ãä»åç·ãã¨å¤æãããããæ
å ±ãã®ãã®ã«ãã¦ã³ããªæååãå
¥ã£ã¦ãã¦ã¯ããã¾ããã
FireFoxã§è»¢éãã¦ã¿ãå
容ãè¦ã¦ã¿ãã¨ã---------------------------102852708831426ãã¨ããããã«ã-ã27æåã¨æ°å15æåã§æ§æããã¦ãããã©ã³ãã ã®æ°åãä»ãã¦ãã¾ããã
\r\nã¯æ¹è¡æåã示ãã¾ãã
ã
â ããã£é¨
ãã©ã¼ã ãã¼ã¿
--ããã¦ã³ããªæååã\r\n Content-Disposition: form-data; name="ããã©ã¼ã ãã¼ã¿åã"\r\n \r\n ããã©ã¼ã ãã¼ã¿ã\r\n
ä¸è¨ãï¼ã¤ã®æ
å ±(ã³ã³ãã³ã)ã示ãã¦ãã¾ãã
ä¾ãã°ãHTMLã®INPUTã¿ã°ã§name="password" value="ponpoko"ã¨å
¥åããã¨ããname=ããã©ã¼ã ãã¼ã¿åããvalue=ããã©ã¼ã ãã¼ã¿ãã¨ç価ã§ãã
ãã¤ããªãã¼ã¿
Content-Disposition: form-data; name="submitfile"; filename="myfile.txt"\r\n Content-Type: application/octet-stream\r\n Content-Transfer-Encoding: binary\r\n \r\n ããã¤ããªãã¼ã¿ã
ãã«ããã¼ããã©ã¼ã ãã¼ã¿ã«ãã¡ã¤ã«ã®å®ä½ãå«ãããå ´åãããã¾ããä¸è¨ããã¤ããªéä¿¡ã®ä¾ã§ããContent-TypeãContent-Transfer-Encodingãªã©ã¯ä»»æã®è¨å®ãè¡ã£ã¦ãã ããã
ã
ããã¿
--ããã¦ã³ããªæååã--\r\n
ãã«ããã¼ããã©ã¼ã ãã¼ã¿ã®çµç«¯ã«ã¯ä¸è¨ã®ããã¿ãæ¸ãè¾¼ã¿ã¾ãã
ã
â ãµã³ãã«
以ä¸ããã«ããã¼ããã©ã¼ã ãã¼ã¿ã®ãã¹ãå 容ã®ãµã³ãã«ã§ããPOST test.php HTTP/1.1\r\n Host: satoxpochi.com\r\n Content-Type: multipart/form-data; boundary=---------------------------102852708831426\r\n Content-Length: ãããã£é¨ã®ãµã¤ãºã\r\n \r\n -----------------------------102852708831426\r\n Content-Disposition: form-data; name="password"\r\n \r\n ponpoko\r\n -----------------------------102852708831426\r\n Content-Disposition: form-data; name="level"\r\n \r\n high\r\n -----------------------------102852708831426\r\n Content-Disposition: form-data; name="filename"; filename="text.txt"\r\n Content-Type: application/octet-stream\r\n Content-Transfer-Encoding: binary\r\n \r\n abcd -----------------------------102852708831426--\r\n
ãã®ä¾ã§ã¯ããã©ã¼ã ãã¼ã¿ã¨ãã¦password=ponpokoãlevel=highãéä¿¡ãããabcdãã¨ã ãæ¸ãããtext.txtããã¤ããªãã¼ã¿ã¨ãã¦éä¿¡å
容ã«å«ããhttp://satoxpochi.com/test.php(åå¨ãã¾ãã)å®ã«ãã¹ããã¦ãã¾ãã
ãããé¨ã®å
容ã¯ã·ã³ãã«ã«ãã¦ãã¦ãContent-Lengthã¯æ£ããå¤ãå
¥ããªãã¨ãããªãã®ã§ãããããããå
¥åããã°ããã ãã§ãPHPã«å¿
è¦ãªæ
å ±ã渡ãã¾ãã
ããããã§ãæ°ã«ãªããã®å¨ã«ãã«ããã¼ããã©ã¼ã ãã¼ã¿ãæãã¤ãããã¾ããã