I'm trying to send a JPG out of my app to a PHP listener and it seems like a ByteArray is the right way to handle this. However, when the request I currently have gets to the server, it has the fileName parameter (which is separate) but not the ByteArray param. In the case of the ByteArray it's missing both the key and value of the field.
In the debugger, I can see the data is in the request... perhaps I'm not collecting it correctly on the PHP side?
here are the relevant parts of my code... all help greatly appreciated (as well as advice to do this in some alternate, more effective, way).
ANDROID:
try {
Part[] parts = new Part[2];
ByteArrayPartSource ps = new ByteArrayPartSource( printFileName, bitmapdata);
parts[0] = new FilePart("fileData", ps);
parts[1] = new StringPart("fileName" ,printFileName);
filePost.setRequestEntity(new MultipartRequestEntity(parts,
filePost.getParams()));
} catch (Exception e) {
Log.d("MY_DEBUG", e.toString());
}
try {
int statusCode1 = client.executeMethod(filePost);
PHP:
$targetPath = "./" . $_REQUEST['fileName'] ;
$newFilePath = $targetPath;
$fh = fopen($newFilePath, 'wb');
//tried both of these, neither seems to work...
fwrite($fh, $GLOBALS["HTTP_RAW_POST_DATA"]) or die("unable to write data");
//and
fwrite($fh, file_get_contents('php://input'));
fclose($fh);
echo "success!";