Vaibhav Bajpai
Vaibhav Bajpai

Reputation: 16784

Better file uploading approach: HTTP post multipart or HTTP put?

Use-case: Upload a simple image file to a server, which clients could later retrieve

  1. Designate a FTP Server for the job.

  2. HTTP Put: It can directly upload files to a server without the need of a server side
    component to handle the bytestream.

  3. HTTP Post: Handle the bytestream by the server side component.

Upvotes: 2

Views: 4033

Answers (3)

Aerik
Aerik

Reputation: 2317

I think to safely use PUT on a public website requires even more effort than using POST (and is less commonly done) due to potential security issues. See http://bitworking.org/news/PUT_SaferOrDangerous.

OTOH, I think there are plenty of resources for safely uploading files with POST and checking them in the server side script, and that this is the more common practice.

Upvotes: 1

Ólafur Waage
Ólafur Waage

Reputation: 70001

What I usually do (via PHP) is HTTP POST.

And employ PHP's move_uploaded_file() to get it to whatever destination I want.

Upvotes: 0

Jason S
Jason S

Reputation: 189736

PUT is only appropriate when you know the URL you are putting to.

You could also do:

4) POST to obtain a URL to which you then PUT the file.

edit: how are you going to get the HTTP server to decide whether it is OK to accept a particular PUT request?

Upvotes: 0

Related Questions