[OSM-dev] gpx upload php code

Bernhard zwischenbrugger bz at datenkueche.com
Wed Mar 17 14:09:01 GMT 2010


hi

I made many of these uploads already, but with normal xml.

Sometimes it's a bit tricky with all the parameters.
But it should be possible with a few lines like this:

----snip----
$options=array(
        'http'=>array(
                'method' => 'POST',
                'header' => "Accept-Encoding: gzip, 
deflate\nContent-Type: text/xml; charset=utf-8\nContent-length: 
".strlen($content)."\n",
                'content' => $content
        )
);
$context= stream_context_create($options);
@$result=file_get_contents($url,false,$context);
----snap---

Sometimes the upload needs some strange headers,....
It's all about parameters.

If you have something like that please send me. The curl version is also ok.

Bernhard



Peter Körner schrieb:
>> Is there a php fragment somewhere
> yep, it's in PEAR:
> http://pear.php.net/package/HTTP_Request
>
>> that handles the multipart-formencode 
> http://pear.php.net/manual/en/package.http.http-request.file-upload.php
>
>> and http auth?
> http://pear.php.net/manual/en/package.http.http-request.basic-auth.php
>
> Have fun.
> Peter





More information about the dev mailing list