我在Windows Server 2012 R2上安装了一个网站,安装了IIS(8?),通过Microsoft Web Platform Installer(PHP 7)安装了PHP。我创建了一个包含以下内容的测试批处理文件:
protected async Task<T> GetData<T>(string dataUri, string accessToken = null, string queryString = null)
{
var url = baseUri + "/" + dataUri + (!string.IsNullOrEmpty(queryString) ? ("?" + queryString) : null);
try
{
using (var httpClient = new HttpClient() { Timeout = new TimeSpan(0, 0, 0, 0, SharedMobileHelper.API_WEB_REQUEST_TIMEOUT) })
{
// Set OAuth authentication header
if (!string.IsNullOrEmpty(accessToken))
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
using (HttpResponseMessage response = await httpClient.GetAsync(url))
{
string content = null;
if (response != null && response.Content != null)
content = await response.Content.ReadAsStringAsync();
if (response.StatusCode == HttpStatusCode.OK ||
response.StatusCode == HttpStatusCode.Created)
{
if (content.Length > 0)
return JsonConvert.DeserializeObject<T>(content);
}
else if (response.StatusCode == HttpStatusCode.InternalServerError)
{
throw new Exception("Internal server error received (" + url + "). " + content);
}
else
{
throw new Exception("Bad or invalid request received (" + url + "). " + content);
}
}
}
}
catch (Exception ex)
{
Log.Error("Could not fetch data via GetData (" + url + ").", ex.ToString());
throw ex;
}
return default(T);
}
我有一个AJAX POST运行我的PHP文件,其中包含:
echo before
md test
echo after
我有从AJAX请求输出到控制台的数据,我得到了之前的,我得到了md命令,但随后它就停止了。
我尝试过:
<?php
system("cmd /c test.bat");
和system()
这些都没有奏效。
关于为什么这不起作用的任何想法?
更新
我可以使用它在C:驱动器中创建一个文件夹,但是我无法在网站目录中创建文件夹。