1

I want to upload a file to my server from some application. How can I code a PHP page to accept this file?

2 Answers 2

3

The application should just include the file in an HTTP POST request as would an HTML form with an input of type file. In the PHP code, the posted file contents would be available in the $_FILES array.

Lots more information here.

Keep in mind that the concept of a "file" doesn't mean the same thing over HTTP that it does on a local computer or on the target server. In HTTP, the "file" is just a stream of data wrapped in an HTTP request or response with a given content type and various other headers, no different from a web page or an image or any other request/response.

2

I would suggest reading the PHP manual chapter on handling file uploads

Not the answer you're looking for? Browse other questions tagged or ask your own question.