Now i have this code:
$fp = fopen("d:\sld\lucas.sld",'r');
$ch =
curl_init("http://localhost/geoserver/rest/styles/Localhost_Style1");
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE,
filesize("d:\sld\lucas.sld"));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type:
application/vnd.ogc.sld+xml')); // sets the content type in the request
header
$passwordStr = "admin:geoserver"; // replace with your
username:password
curl_setopt($ch, CURLOPT_USERPWD, $passwordStr);
And I see that my Localhost_Style1.xml is update (file timestamp) but
the .sld is created with a default style not my style...
Met vriendelijke groet,
Lucas Heezen
Covadis b.v.
t: 026 3616600
Geograaf 12
f: 026 3612317
6921 EW Duiven
e: [email protected] <mailto:[email protected]>
Van: Lucas Heezen - Covadis
Verzonden: donderdag 22 september 2011 9:35
Aan: [email protected]
Onderwerp: Upload a SLD file to geoserver
Hello,
I'm having a problem with upload a SLD file to geoserver using REST.
This is the code I;m having so far:
// URL on which we have to post data
$url = "http://localhost/geoserver/rest/styles/line";
// Any other field you might want to catch
$post_data['name'] = "line";
// File you want to upload/post
$post_data['file'] = "@d:/sld/lucas.sld";
// Initialize cURL
$ch = curl_init();
// Set URL on which you want to post the Form and/or data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "admin:geoserver");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type:
application/vnd.ogc.sld+xml"));
// Data+Files to be posted
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
// Pass TRUE or 1 if you want to wait for and catch the response
against the request made
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// For Debug mode; shows up any error encountered during the
operation
curl_setopt($ch, CURLOPT_VERBOSE, 1);
// Execute the request
$response = curl_exec($ch);
// Just for debug: to see response
echo $response;
But I get nog error and the file is not uploaded...any idea?
Met vriendelijke groet,
Lucas Heezen
Covadis b.v.
t: 026 3616600
Geograaf 12
f: 026 3612317
6921 EW Duiven
e: [email protected] <mailto:[email protected]>
<<image001.gif>>
------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________ Geoserver-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geoserver-users
