<?php
header("Content-Type:text/html;charset=utf-8");
//check params
/*
//地图上传 php www post接口,客户端使用
WWWForm form = new WWWForm();
form.AddField("json_data", str);
form.AddField("file_name", "test_upload1");
StartCoroutine(upload(form));
}
string url = "127.0.0.1:7013/upload.php";
返回字符串类型
ok表示成功 其余表示失败 具体可看源代码echo值
*/
if (isset($_POST['file_name']) && isset($_POST['json_data']))
{
$json = $_POST['json_data'];
$len = strlen($json);
if ($len > 100 * 1024) // 100kb
{// out of size limit
echo 'out-of-size';
}
else
{
$upload_dir = "../../../www/s/map";
$dir = iconv("UTF-8", "GBK", $upload_dir);
if (!file_exists($dir))
{
mkdir($dir, 0777, true);
}
else
{
}
$file = $upload_dir . "/" . $_POST['file_name'] . ".json";
if (is_file($file))
{
echo 'exist';
}
else
{
file_put_contents($file, $json);
echo 'ok';
}
}
}
else
{
echo 'error';
}