如果我试图发布像#34; abc"我收到了回复,但当我尝试发布大量数据(如108 KB)时,它没有显示响应可能是我需要增加一些限制,但我无法访问php.ini文件。
还有其他方法吗?
我正在发布android的数据,所以在android中有任何字符串缩短编码并在php中解码可用。我已经使用base64来获取图像数据。
我的PHP代码回应了回报。
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');
if(isset($_POST['incidentDetails']))
{
echo 'Responce from server: ' . $_POST['incidentDetails'];
}
else
{
echo 'Request without paramenter';
}
?>
网址 - http://bumba27.byethost16.com/incidentManagments/api/adding_incident_details.php
我需要发布参数名称incidentDetails- http://www.filedropper.com/log_2
Android代码
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://bumba27.byethost16.com/incidentManagments/api/adding_incident_details.php");
try
{
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("incidentDetails", headerData));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
responseCode = response.getStatusLine().getStatusCode();
responseBody = EntityUtils.toString(response.getEntity());
}
catch (Throwable t )
{
Log.d("Error Time of Login",t+"");
}
答案 0 :(得分:1)
您是否确保在发送图像数据的HTML表单上的表单标记中包含enctype =“multipart / form-data”?
<form name="someform" id="someform" enctype="multipart/form-data" method="post" action="somefile.php">
修改强> 根据PHP.NET网站,你必须做一个保存文件的过程 - 不只是打印出$ _POST数组:
$name= $_FILES["myfile"]["name"];
$type= $_FILES["myfile"]["type"];
$size= $_FILES["myfile"]["size"];
$temp= $_FILES["myfile"]["temp_name"];
$error= $_FILES["myfile"]["error"];
if ($error > 0)
die("Error uploading file! code $error.");
else
{
if($type=="image/png" || $size > 2000000)//condition for the file
{
die("Format not allowed or file size too big!");
}
else
{
move_uploaded_file($temp, "uploaded/" .$name);
echo "Upload complete!";
}
}