我正在尝试使用php将PostGIS中的PostGIS表上传到GeoServer。但是,我有问题将cURL转换为等效的PHP。
我正在获取Http代码:405
卷曲:
curl -v -u admin:geoserver -X PUT-H "Content-type: text/xml" -T pgstores.xml \
http://localhost:9090/geoserver/rest/workspaces/testworkspace/datastores.xml
PHP:
$url = "http://localhost:9090/geoserver/rest/workspaces/testworkspace/datastores.xml";
$headers = array('Content-Type: text/xml', 'Accept: text/xml');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_USERPWD, GEOSERVER_USER);
$path = getcwd()."/uploads/pgstores.xml";
$fp = fopen($path, "r");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_PUT, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_UPLOAD, true);
curl_setopt($ch, CURLOPT_REFERER, true);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($path));
任何帮助都将不胜感激。