android - PHP receive http post request as $_POST -
i trying receive image data in php using $_post if trying post small string "abc" getting response when try post huge data 108 kb it's not showing response might need increase limit don't have access in php.ini file.
is there other way?
and posting data android there string shorten encoding in android , decoding in php available. used base64 image data.
my php code echo return.
<?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 server: ' . $_post['incidentdetails']; } else { echo 'request without paramenter'; } ?>
the url - http://bumba27.byethost16.com/incidentmanagments/api/adding_incident_details.php
i need post parameter name incidentdetails- http://www.filedropper.com/log_2
android code
// create new httpclient , 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+""); }
are making sure have enctype="multipart/form-data" in form tag on html form sending image data?
<form name="someform" id="someform" enctype="multipart/form-data" method="post" action="somefile.php">
edit: according php.net website, have process save files - not print out $_post array:
$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 file { die("format not allowed or file size big!"); } else { move_uploaded_file($temp, "uploaded/" .$name); echo "upload complete!"; } }
Comments
Post a Comment