What is the code that you use to write the file? The code you showed doesn't do that.
Maybe your webserver doesn't allow PUT by default. If it doesn't you should enable it (and have a handler/module that processes the put. Apache can use the mod_actions module to handle PUTs.