Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 生成器stringBuilder=新的stringBuilder(); 试一试{ 网址; HttpUrlConnectionHttpUrlConnectionObject; 输出流输出流; BufferedWriter bufferedWriterObject; BufferedReader bufferedReaderObject; int RC; url=新url(请求url); httpURLConnectionObject=(HttpURLConnection)url.openConnection(); httpURLConnectionObject.setReadTimeout(19000); httpURLConnectionObject.setConnectTimeout(19000); httpURLConnectionObject.setRequestMethod(“POST”); httpURLConnectionObject.setDoInput(true); httpURLConnectionObject.setDoOutput(true); OutPutStream=httpURLConnectionObject.getOutputStream(); bufferedWriterObject=新的BufferedWriter( 新的OutputStreamWriter(OutPutStream,“UTF-8”); 写入(bufferedWriterDataFN(PData)); BufferedWriteObject.flush(); BufferedWriteObject.close(); OutPutStream.close(); RC=httpURLConnectionObject.getResponseCode(); if(RC==HttpsURLConnection.HTTP\u确定){ bufferedReaderObject=新的BufferedReader(新的InputStreamReader(httpURLConnectionObject.getInputStream()); stringBuilder=新的stringBuilder(); 字符串RC2; 而((RC2=bufferedReaderObject.readLine())!=null){ stringBuilder.append(RC2); } } }捕获(例外e){ e、 printStackTrace(); } 返回stringBuilder.toString(); } 私有字符串bufferedWriterDataFN(HashMap HashMapParams)引发UnsupportedEncodingException{ StringBuilderStringBuilderObject; stringBuilderObject=新的StringBuilder(); for(Map.Entry键:HashMapParams.entrySet()){ 如果(检查) 检查=错误; 其他的 stringBuilderObject.append(“&”); stringBuilderObject.append(urlcoder.encode(KEY.getKey(),“UTF-8”); stringBuilderObject.append(“”); stringBuilderObject.append(urlcoder.encode(KEY.getValue(),“UTF-8”); } 返回stringBuilderObject.toString(); } } }_Php_Android_Mysql - Fatal编程技术网

Php 生成器stringBuilder=新的stringBuilder(); 试一试{ 网址; HttpUrlConnectionHttpUrlConnectionObject; 输出流输出流; BufferedWriter bufferedWriterObject; BufferedReader bufferedReaderObject; int RC; url=新url(请求url); httpURLConnectionObject=(HttpURLConnection)url.openConnection(); httpURLConnectionObject.setReadTimeout(19000); httpURLConnectionObject.setConnectTimeout(19000); httpURLConnectionObject.setRequestMethod(“POST”); httpURLConnectionObject.setDoInput(true); httpURLConnectionObject.setDoOutput(true); OutPutStream=httpURLConnectionObject.getOutputStream(); bufferedWriterObject=新的BufferedWriter( 新的OutputStreamWriter(OutPutStream,“UTF-8”); 写入(bufferedWriterDataFN(PData)); BufferedWriteObject.flush(); BufferedWriteObject.close(); OutPutStream.close(); RC=httpURLConnectionObject.getResponseCode(); if(RC==HttpsURLConnection.HTTP\u确定){ bufferedReaderObject=新的BufferedReader(新的InputStreamReader(httpURLConnectionObject.getInputStream()); stringBuilder=新的stringBuilder(); 字符串RC2; 而((RC2=bufferedReaderObject.readLine())!=null){ stringBuilder.append(RC2); } } }捕获(例外e){ e、 printStackTrace(); } 返回stringBuilder.toString(); } 私有字符串bufferedWriterDataFN(HashMap HashMapParams)引发UnsupportedEncodingException{ StringBuilderStringBuilderObject; stringBuilderObject=新的StringBuilder(); for(Map.Entry键:HashMapParams.entrySet()){ 如果(检查) 检查=错误; 其他的 stringBuilderObject.append(“&”); stringBuilderObject.append(urlcoder.encode(KEY.getKey(),“UTF-8”); stringBuilderObject.append(“”); stringBuilderObject.append(urlcoder.encode(KEY.getValue(),“UTF-8”); } 返回stringBuilderObject.toString(); } } }

Php 生成器stringBuilder=新的stringBuilder(); 试一试{ 网址; HttpUrlConnectionHttpUrlConnectionObject; 输出流输出流; BufferedWriter bufferedWriterObject; BufferedReader bufferedReaderObject; int RC; url=新url(请求url); httpURLConnectionObject=(HttpURLConnection)url.openConnection(); httpURLConnectionObject.setReadTimeout(19000); httpURLConnectionObject.setConnectTimeout(19000); httpURLConnectionObject.setRequestMethod(“POST”); httpURLConnectionObject.setDoInput(true); httpURLConnectionObject.setDoOutput(true); OutPutStream=httpURLConnectionObject.getOutputStream(); bufferedWriterObject=新的BufferedWriter( 新的OutputStreamWriter(OutPutStream,“UTF-8”); 写入(bufferedWriterDataFN(PData)); BufferedWriteObject.flush(); BufferedWriteObject.close(); OutPutStream.close(); RC=httpURLConnectionObject.getResponseCode(); if(RC==HttpsURLConnection.HTTP\u确定){ bufferedReaderObject=新的BufferedReader(新的InputStreamReader(httpURLConnectionObject.getInputStream()); stringBuilder=新的stringBuilder(); 字符串RC2; 而((RC2=bufferedReaderObject.readLine())!=null){ stringBuilder.append(RC2); } } }捕获(例外e){ e、 printStackTrace(); } 返回stringBuilder.toString(); } 私有字符串bufferedWriterDataFN(HashMap HashMapParams)引发UnsupportedEncodingException{ StringBuilderStringBuilderObject; stringBuilderObject=新的StringBuilder(); for(Map.Entry键:HashMapParams.entrySet()){ 如果(检查) 检查=错误; 其他的 stringBuilderObject.append(“&”); stringBuilderObject.append(urlcoder.encode(KEY.getKey(),“UTF-8”); stringBuilderObject.append(“”); stringBuilderObject.append(urlcoder.encode(KEY.getValue(),“UTF-8”); } 返回stringBuilderObject.toString(); } } },php,android,mysql,Php,Android,Mysql,PHP代码 <?php if($_SERVER['REQUEST_METHOD']=='POST'){ $image = $_POST['image_path']; $image1 = $_POST['image_path1']; $name = $_POST['image_name']; $name1 = $_POST['image_name1']; define('HOST','localhost'); define('USER',

PHP代码

<?php

if($_SERVER['REQUEST_METHOD']=='POST'){

    $image = $_POST['image_path'];
    $image1 = $_POST['image_path1'];
    $name = $_POST['image_name'];
    $name1 = $_POST['image_name1'];

    define('HOST','localhost');
    define('USER','root');
    define('PASS','');
    define('DB','multiple');

    $con = mysqli_connect(HOST,USER,PASS,DB) or die('Unable to Connect to Server');

    $path = "uploads1/$name.png";
    $path1 = "uploads1/$name1.png";

    $actualpath = "http://10.0.3.2/$path";
    $actualpath1 = "http://10.0.3.2/$path1";

    $sql = "INSERT INTO multiple2 (image1,name1,image2,name2,time) VALUES ('id','$actualpath','$name','$actualpath1','$name1',now())";

    if(mysqli_query($con,$sql)){
        file_put_contents($path,base64_decode($image));
        file_put_contents($path1,base64_decode($image1));
        echo "Successfully Uploaded";
    }

    mysqli_close($con);

}else{
    echo "Error";
}

我通过在一个迭代循环中循环所有图像而成功。

您已经用PHP标记了这个问题。但是我没有看到任何PHP代码。谢谢你的关注。我想把图片上传到服务器上,并用PHP MySQL将路径写入数据库。这就是我要问的。。我们应该查找的PHP代码在哪里,以便帮助您解决问题。PHP代码现附。谢谢你的回复。你的插入查询是错误的。使用虚拟数据在MySQL中运行它。你会得到错误。您将在insert in values部分传递id,而不是在insert into abc()中传递id,并使用PHP准备的语句。
<?php

if($_SERVER['REQUEST_METHOD']=='POST'){

    $image = $_POST['image_path'];
    $image1 = $_POST['image_path1'];
    $name = $_POST['image_name'];
    $name1 = $_POST['image_name1'];

    define('HOST','localhost');
    define('USER','root');
    define('PASS','');
    define('DB','multiple');

    $con = mysqli_connect(HOST,USER,PASS,DB) or die('Unable to Connect to Server');

    $path = "uploads1/$name.png";
    $path1 = "uploads1/$name1.png";

    $actualpath = "http://10.0.3.2/$path";
    $actualpath1 = "http://10.0.3.2/$path1";

    $sql = "INSERT INTO multiple2 (image1,name1,image2,name2,time) VALUES ('id','$actualpath','$name','$actualpath1','$name1',now())";

    if(mysqli_query($con,$sql)){
        file_put_contents($path,base64_decode($image));
        file_put_contents($path1,base64_decode($image1));
        echo "Successfully Uploaded";
    }

    mysqli_close($con);

}else{
    echo "Error";
}