Author Topic: เรียนรู้การใช้งาน curl  (Read 5211 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
เรียนรู้การใช้งาน curl
« on: สิงหาคม 18, 2014, 03:19:57 PM »
http://httpkit.com/resources/HTTP-from-the-Command-Line/

Request :

#curl http://echo.httpkit.com

Response :

{
  "method": "GET",
  "uri": "/",
  "path": {
    "name": "/",
    "query": "",
    "params": {}
  },
  "headers": {
    "host": "echo.httpkit.com",
    "user-agent": "curl/7.24.0 ...",
    "accept": "*/*"
  },
  "body": null,
  "ip": "28.169.144.35",
  "powered-by": "http://httpkit.com",
  "docs": "http://httpkit.com/echo"
}

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: เรียนรู้การใช้งาน curl
« Reply #1 on: สิงหาคม 18, 2014, 04:23:03 PM »
To upload a file using the command line, do the following:
Code

curl "http://example.com/upload.php" -F myfile=@"/path/to/file"

Example:
Code

curl "http://example.com/upload.php" -F myfile=@"~/Desktop/image.png"

And using authentication:
Code

curl -u username:password "http://example.com/upload.php" -F myfile=@"~/Desktop/image.png"

NOTE: Change myfile to the file input value name. <input name="myfile" type="file" />
PHP

// upload.php
var_dump($_POST);
var_dump($_FILES);

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email