Android PHP GET Base64

Android PHP GET Base64,php,android,database,Php,Android,Database,我想从我的android应用程序解析一些数据到我的网站。其中一个数据是pdf,而另一组数据只是整数或字符串。除非我想解析包含pdf的base64字符串,否则我保存数据的尝试是有效的。在数据库中,新插入的行在每个字段中都为空。在检索base64字符串之后,我要做的是使用base64字符串创建一个BLOB 安卓 //Read text from file BufferedReader input = null; input = new Buffere

我想从我的android应用程序解析一些数据到我的网站。其中一个数据是pdf,而另一组数据只是整数或字符串。除非我想解析包含pdf的base64字符串,否则我保存数据的尝试是有效的。在数据库中,新插入的行在每个字段中都为空。在检索base64字符串之后,我要做的是使用base64字符串创建一个BLOB

安卓

 //Read text from file
            BufferedReader input = null;
            input = new BufferedReader(
                    new InputStreamReader(openFileInput(myFile)));
            String line;
            StringBuffer buffer = new StringBuffer();
            while ((line = input.readLine()) != null) {
                buffer.append(line + "\n");
            }
            String text = buffer.toString();

            byte[] byteArray = text.getBytes("UTF-8");

            String base64= Base64.encodeToString(byteArray, Base64.DEFAULT);

            Log.d("HERE I AM", base64);

            url = new URL("http://website.com/kundenexecute.php" +
                    "?firstname=" + firstname + "&"
                    + "lastname=" + lastname + "&"
                    + "postalcode=" + postalcode + "&"
                    + "citytext=" + citytext + "&"
                    + "address=" + address + "&"
                    + "e_mail=" + e_mail + "&"
                    + "birthday=" + birthday+ "&"
                    + "test=" + base64);
            //  + "pdf=" + blobData);


            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
            InputStream a = new BufferedInputStream(urlConnection.getInputStream());
            postalcode = String.valueOf(Integer.valueOf(convertStreamToString(a)));
            urlConnection.disconnect();
PHP文件

<?php       
include "db.inc.php";
include "redirect.php";
session_start();

$conn = mysqli_connect($db_server, $db_user, $db_password, $db_name)  or die("you did not connect bozo");


$postleitzahl = $_GET['postalcode'];
$firstname = $_GET['firstname'];
$lastname = $_GET['lastname'];
$citytext = $_GET['citytext'];
$address = $_GET['address'];
$e_mail = $_GET['e_mail'];
$birthday=$_GET['birthday'];
$test=$_GET['test'];

//echo " base64 string";
echo $test;

$statement = $conn->prepare("INSERT INTO kunden(kunden_plz, kunden_nachname, kunden_vorname, kunden_adresse, kunden_ort, kunden_email, kunden_geburtsdatum) VALUES (?,?,?,?,?,?,?)");

$statement->bind_param("sssssss", $postleitzahl,       $firstname,$lastname,$citytext,$address,$e_mail,$birthday);
$statement->execute();

在尝试使用base64和不使用base64之前数据库的外观


String text=buffer.toString()。它将不包含您的pdf文件。您不能将pdf文件放在字符串中,因为这样的文件不是文本。您也不能使用BufferedReader和readLine来读取pdf文件。我不会使用GET来执行此操作:很可能您在通往服务器的网络路径上的某个地方破坏了最大URL长度。我会将您的所有参数发布在一个JSON中,内容类型为
application/JSON
,php端的JSON_会对有效负载进行解码。我该怎么做?我曾经试着用一篇文章来做这件事,但它总是空的,或者根本就没有进入数据库。关于pdf,我现在如何检索它?