user1394647
user1394647

Reputation:

PHP that accepts file upload from a single HTTP POST

I'm trying to figure out how to get a server to accept a file through HTTP post in one step - without going through all the trouble of creating an html form and clicking the submit button.

I know how to write a PHP/HTML package that accomplishes the following:

I create an HTML file with a form that calls a php script when the submit button is clicked.

I'd like to change this to the following:

Said another way, I'd like to send the file directly to the php script without going through the form step.

Much thanks for any guidance.

Upvotes: 0

Views: 1629

Answers (1)

dev-null-dweller
dev-null-dweller

Reputation: 29462

http://curl.haxx.se/docs/httpscripting.html

4.3 File Upload POST

<form method="POST" enctype='multipart/form-data' action="upload.cgi">
  <input type=file name=upload>
  <input type=submit name=press value="OK">
</form>

command line equivalent:

 curl --form upload=@localfilename --form press=OK [URL]

Upvotes: 1

Related Questions