久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='GXIug'></tfoot>
    • <bdo id='GXIug'></bdo><ul id='GXIug'></ul>

    1. <i id='GXIug'><tr id='GXIug'><dt id='GXIug'><q id='GXIug'><span id='GXIug'><b id='GXIug'><form id='GXIug'><ins id='GXIug'></ins><ul id='GXIug'></ul><sub id='GXIug'></sub></form><legend id='GXIug'></legend><bdo id='GXIug'><pre id='GXIug'><center id='GXIug'></center></pre></bdo></b><th id='GXIug'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='GXIug'><tfoot id='GXIug'></tfoot><dl id='GXIug'><fieldset id='GXIug'></fieldset></dl></div>

      <small id='GXIug'></small><noframes id='GXIug'>

      1. <legend id='GXIug'><style id='GXIug'><dir id='GXIug'><q id='GXIug'></q></dir></style></legend>

        從android在php服務(wù)器上上傳多個(gè)圖像

        Uploading multiple image on php server from android(從android在php服務(wù)器上上傳多個(gè)圖像)
                  <tbody id='RL2J6'></tbody>

                <small id='RL2J6'></small><noframes id='RL2J6'>

                <tfoot id='RL2J6'></tfoot>

                <i id='RL2J6'><tr id='RL2J6'><dt id='RL2J6'><q id='RL2J6'><span id='RL2J6'><b id='RL2J6'><form id='RL2J6'><ins id='RL2J6'></ins><ul id='RL2J6'></ul><sub id='RL2J6'></sub></form><legend id='RL2J6'></legend><bdo id='RL2J6'><pre id='RL2J6'><center id='RL2J6'></center></pre></bdo></b><th id='RL2J6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='RL2J6'><tfoot id='RL2J6'></tfoot><dl id='RL2J6'><fieldset id='RL2J6'></fieldset></dl></div>
                <legend id='RL2J6'><style id='RL2J6'><dir id='RL2J6'><q id='RL2J6'></q></dir></style></legend>
                  <bdo id='RL2J6'></bdo><ul id='RL2J6'></ul>

                • 本文介紹了從android在php服務(wù)器上上傳多個(gè)圖像的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  此特定服務(wù)器端 php 代碼的幫助我對(duì) php 一無(wú)所知,我必須將三張圖片從 android 上傳到此 php 頁(yè)面.

                  我嘗試了很多方法并進(jìn)行了搜索,但沒有任何教程或任何內(nèi)容對(duì)我沒有幫助,我的 android 代碼運(yùn)行正常.DNS 也已配置,但圖像未顯示在服務(wù)器端.請(qǐng)幫我寫java代碼.

                  PHP:

                   0){header("HTTP/1.1 400 錯(cuò)誤請(qǐng)求");回聲錯(cuò)誤:".$_FILES["file1"]["error"] ."<br/>";}否則如果 ($_FILES["file2"]["error"] > 0){header("HTTP/1.1 400 錯(cuò)誤請(qǐng)求");回聲錯(cuò)誤:".$_FILES["file1"]["error"] ."<br/>";}否則如果 ($_FILES["file3"]["error"] > 0){header("HTTP/1.1 400 錯(cuò)誤請(qǐng)求");回聲錯(cuò)誤:".$_FILES["file1"]["error"] ."<br/>";}別的{如果 ($_FILES["file1"]["error"] > 0){回聲錯(cuò)誤:".$_FILES["file1"]["error"] ."<br/>";}別的{回聲上傳:".$_FILES["file1"]["name"] ."<br/>";回聲類型:".$_FILES["file1"]["type"] ."<br/>";回聲大小:".($_FILES["file1"]["size"]/1024)."Kb<br/>";回聲存儲(chǔ)在:".$_FILES["file1"]["tmp_name"]."<br/>";}//$target_path = "上傳/";$target_path = "elp/pendingimages/";$target_path = $target_path .基本名稱($_FILES['file1']['name']);if(move_uploaded_file($_FILES['file1']['tmp_name'], $target_path)) {回聲文件".基本名稱($_FILES['file1']['name'])."已上傳";}別的{echo "上傳文件時(shí)出錯(cuò),請(qǐng)重試!";}如果 ($_FILES["file2"]["error"] > 0){回聲錯(cuò)誤:".$_FILES["file2"]["error"] ."<br/>";}別的{回聲上傳:".$_FILES["file2"]["name"] ."<br/>";回聲類型:".$_FILES["file2"]["type"] ."<br/>";回聲大小:".($_FILES["file2"]["size"]/1024)."Kb<br/>";回聲存儲(chǔ)在:".$_FILES["file2"]["tmp_name"]."<br/>";}//$target_path = "上傳/";$target_path = "elp/pendingimages/";$target_path = $target_path .基本名稱($_FILES['file2']['name']);如果(move_uploaded_file($_FILES['file2']['tmp_name'],$target_path)){回聲文件".基本名稱($_FILES['file2']['name'])."已上傳";}別的{echo "上傳文件時(shí)出錯(cuò),請(qǐng)重試!";}如果 ($_FILES["file3"]["error"] > 0){回聲錯(cuò)誤:".$_FILES["file3"]["error"] ."<br/>";}別的{回聲上傳:".$_FILES["file3"]["name"] ."<br/>";回聲類型:".$_FILES["file3"]["type"] ."<br/>";回聲大小:".($_FILES["file3"]["size"]/1024)."Kb<br/>";回聲存儲(chǔ)在:".$_FILES["file3"]["tmp_name"]."<br/>";}//$target_path = "上傳/";$target_path = "elp/pendingimages/";$target_path = $target_path .基本名稱($_FILES['file3']['name']);if(move_uploaded_file($_FILES['file3']['tmp_name'], $target_path)) {回聲文件".基本名稱($_FILES['file3']['name'])."已上傳";}別的{echo "上傳文件時(shí)出錯(cuò),請(qǐng)重試!";}}?>

                  Java:

                  public class TryprojectActivity extends Activity {輸入流是;int pic_count = 0;位圖 bitmap=null;FileInputStream in1,in2,in3;BufferedInputStream buf;@覆蓋公共無(wú)效onCreate(捆綁冰柱){super.onCreate(冰柱);setContentView(R.layout.main);嘗試 {in1 = new FileInputStream("/sdcard/1.jpg");}抓住(FileNotFoundException e2){//TODO 自動(dòng)生成的 catch 塊e2.printStackTrace();}嘗試 {in2 = new FileInputStream("/sdcard/2.jpg");} catch (FileNotFoundException e1) {//TODO 自動(dòng)生成的 catch 塊e1.printStackTrace();}嘗試 {in3 = new FileInputStream("/sdcard/3.jpg");}抓住(FileNotFoundException e1){//TODO 自動(dòng)生成的 catch 塊e1.printStackTrace();}位圖 bitmapOrg1 = BitmapFactory.decodeStream(in1);ByteArrayOutputStream bao1 = new ByteArrayOutputStream();bitmapOrg1.compress(Bitmap.CompressFormat.JPEG, 90, bao1);字節(jié) [] imagearray1 = bao1.toByteArray();String ba1=Base64.encode(imagearray1);位圖 bitmapOrg2 = BitmapFactory.decodeStream(in2);ByteArrayOutputStream bao2 = new ByteArrayOutputStream();bitmapOrg2.compress(Bitmap.CompressFormat.JPEG, 90, bao2);字節(jié) [] imagearray2 = bao2.toByteArray();String ba2=Base64.encode(imagearray2);位圖 bitmapOrg3 = BitmapFactory.decodeStream(in3);ByteArrayOutputStream bao3 = new ByteArrayOutputStream();bitmapOrg3.compress(Bitmap.CompressFormat.JPEG, 90, bao3);字節(jié) [] imagearray3 = bao3.toByteArray();String ba3=Base64.encode(imagearray3);列表nameValuePairs = new ArrayList(3);nameValuePairs.add(new BasicNameValuePair("image1",ba1));nameValuePairs.add(new BasicNameValuePair("image2",ba2));nameValuePairs.add(new BasicNameValuePair("image3",ba3));嘗試{HttpClient httpclient = new DefaultHttpClient();HttpPost httppost = new HttpPost("http://helpdesk.cispl.com/upload_file.php");UrlEncodedFormEntity obj = new UrlEncodedFormEntity(nameValuePairs);obj.setChunked(true);httppost.setEntity(obj);HttpResponse 響應(yīng) = httpclient.execute(httppost);HttpEntity entity = response.getEntity();//is = entity.getContent();httpclient.getConnectionManager().shutdown();}捕獲(異常 e){//CommonFunctions.writeLOG(ctx.getClass().toString(), e.toString());//CommonFunctions.showToast(ctx, "無(wú)法發(fā)布捕獲的圖像文件:" +//e.toString());}}

                  解決方案

                  看起來(lái)你的 PHP 是正確的.

                  在您的設(shè)備上使用帶有 MultipartEntity 數(shù)據(jù)類型的 HTTP POST 請(qǐng)求.閱讀更多此處

                  編輯

                  來(lái)自我的鏈接的示例:

                  您必須下載額外的庫(kù)才能運(yùn)行 MultipartEntity

                  1) 從 http://james.apache 下載 httpcomponents-client-4.1.zip.org/download.cgi#Apache_Mime4J 并將 apache-mime4j-0.6.1.jar 添加到您的項(xiàng)目中.

                  2) 從 http://hc.apache 下載 httpcomponents-client-4.1-bin.zip.org/downloads.cgi 并將 httpclient-4.1.jar、httpcore-4.1.jar 和 httpmime-4.1.jar 添加到您的項(xiàng)目中.

                  3) 使用下面的示例代碼.

                  <前><代碼>私有 DefaultHttpClient mHttpClient;公共服務(wù)器通信(){HttpParams params = new BasicHttpParams();params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);mHttpClient = new DefaultHttpClient(params);}public void uploadUserPhoto(File image1, File image2, File image3) {嘗試 {HttpPost httppost = new HttpPost("some url");MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);multipartEntity.addPart("Title", new StringBody("Title"));multipartEntity.addPart("Nick", new StringBody("Nick"));multipartEntity.addPart("Email", new StringBody("Email"));multipartEntity.addPart("Description", new StringBody(Settings.SHARE.TEXT));multipartEntity.addPart("file1", new FileBody(image1));multipartEntity.addPart("file2", new FileBody(image2));multipartEntity.addPart("file3", new FileBody(image3));httppost.setEntity(multipartEntity);mHttpClient.execute(httppost, new PhotoUploadResponseHandler());} 捕獲(異常 e){Log.e(ServerCommunication.class.getName(), e.getLocalizedMessage(), e);}}私有類 PhotoUploadResponseHandler 實(shí)現(xiàn)了 ResponseHandler {@覆蓋公共對(duì)象 handleResponse(HttpResponse 響應(yīng))拋出 ClientProtocolException,IOException {HttpEntity r_entity = response.getEntity();String responseString = EntityUtils.toString(r_entity);Log.d("上傳", responseString);返回空;}}

                  Help for this specific server side php code I don't have any knowledge of php and I have to upload three images from android to this php page.

                  I have tried many methods and searched for it but no tutorial or anything didn't help me my android code is working properly. DNS also configured but images aren't shown at the server side. Please help me with java code.

                  PHP:

                  <?php
                  if ($_FILES["file1"]["error"] > 0)
                  {
                      header("HTTP/1.1 400 Bad Request");
                      echo "Error: " . $_FILES["file1"]["error"] . "<br />";
                  }
                  else if ($_FILES["file2"]["error"] > 0)
                  {
                      header("HTTP/1.1 400 Bad Request");
                      echo "Error: " . $_FILES["file1"]["error"] . "<br />";
                  }
                  else if ($_FILES["file3"]["error"] > 0)
                  {
                      header("HTTP/1.1 400 Bad Request");
                      echo "Error: " . $_FILES["file1"]["error"] . "<br />";
                  }
                  else
                  {
                      if ($_FILES["file1"]["error"] > 0)
                      {
                          echo "Error: " . $_FILES["file1"]["error"] . "<br />";
                      }
                      else
                      {
                          echo "Upload: " . $_FILES["file1"]["name"] . "<br />";
                          echo "Type: " . $_FILES["file1"]["type"] . "<br />";
                          echo "Size: " . ($_FILES["file1"]["size"] / 1024) . " Kb<br />";
                          echo "Stored in: " . $_FILES["file1"]["tmp_name"]. "<br />";
                      }
                  
                      //$target_path = "uploads/";
                      $target_path = "elp/pendingimages/";
                  
                      $target_path = $target_path . basename( $_FILES['file1']['name']); 
                  
                      if(move_uploaded_file($_FILES['file1']['tmp_name'], $target_path)) {
                          echo "The file ".  basename( $_FILES['file1']['name']). 
                              " has been uploaded"; 
                      } 
                      else{
                          echo "There was an error uploading the file, please try again!";
                      }
                  
                      if ($_FILES["file2"]["error"] > 0)
                      {
                          echo "Error: " . $_FILES["file2"]["error"] . "<br />";
                      }
                      else
                      {
                          echo "Upload: " . $_FILES["file2"]["name"] . "<br />";
                          echo "Type: " . $_FILES["file2"]["type"] . "<br />";
                          echo "Size: " . ($_FILES["file2"]["size"] / 1024) . " Kb<br />";
                          echo "Stored in: " . $_FILES["file2"]["tmp_name"]. "<br />";
                      }
                  
                      //$target_path = "uploads/";
                      $target_path = "elp/pendingimages/";
                  
                      $target_path = $target_path . basename( $_FILES['file2']['name']); 
                  
                      if(move_uploaded_file($_FILES['file2']['tmp_name'], $target_path)) {
                          echo "The file ".  basename( $_FILES['file2']['name']). 
                          " has been uploaded";
                      } 
                      else{
                          echo "There was an error uploading the file, please try again!";
                      }
                  
                      if ($_FILES["file3"]["error"] > 0)
                      {
                          echo "Error: " . $_FILES["file3"]["error"] . "<br />";
                      }
                      else
                      {
                          echo "Upload: " . $_FILES["file3"]["name"] . "<br />";
                          echo "Type: " . $_FILES["file3"]["type"] . "<br />";
                          echo "Size: " . ($_FILES["file3"]["size"] / 1024) . " Kb<br />";
                          echo "Stored in: " . $_FILES["file3"]["tmp_name"]. "<br />";
                      }
                  
                  
                      //$target_path = "uploads/";
                      $target_path = "elp/pendingimages/";
                  
                      $target_path = $target_path . basename( $_FILES['file3']['name']);  
                  
                      if(move_uploaded_file($_FILES['file3']['tmp_name'], $target_path)) {
                          echo "The file ".  basename( $_FILES['file3']['name']). 
                              " has been uploaded";
                      } 
                      else{
                          echo "There was an error uploading the file, please try again!";
                      }
                  }
                  
                  ?>
                  

                  Java:

                  public class TryprojectActivity extends Activity {
                      InputStream is;
                      int pic_count = 0;
                      Bitmap bitmap=null;
                      FileInputStream in1,in2,in3;
                      BufferedInputStream buf;
                  
                  @Override
                  public void onCreate(Bundle icicle) {
                      super.onCreate(icicle);
                      setContentView(R.layout.main);
                  
                          try {
                              in1 = new FileInputStream("/sdcard/1.jpg");
                          } 
                          catch (FileNotFoundException e2) {
                          // TODO Auto-generated catch block
                              e2.printStackTrace();
                          }
                  
                          try {
                              in2 = new FileInputStream("/sdcard/2.jpg");
                          } catch (FileNotFoundException e1) {
                          // TODO Auto-generated catch block
                          e1.printStackTrace();
                      } 
                  
                      try {
                          in3 = new FileInputStream("/sdcard/3.jpg");
                      } 
                      catch (FileNotFoundException e1) {
                          // TODO Auto-generated catch block
                          e1.printStackTrace();
                      } 
                  
                      Bitmap bitmapOrg1 = BitmapFactory.decodeStream(in1);
                      ByteArrayOutputStream bao1 = new ByteArrayOutputStream();
                      bitmapOrg1.compress(Bitmap.CompressFormat.JPEG, 90, bao1);
                      byte [] imagearray1 = bao1.toByteArray();
                      String ba1=Base64.encode(imagearray1);
                  
                      Bitmap bitmapOrg2 = BitmapFactory.decodeStream(in2);
                      ByteArrayOutputStream bao2 = new ByteArrayOutputStream();
                      bitmapOrg2.compress(Bitmap.CompressFormat.JPEG, 90, bao2);
                      byte [] imagearray2 = bao2.toByteArray();
                      String ba2=Base64.encode(imagearray2);
                  
                      Bitmap bitmapOrg3 = BitmapFactory.decodeStream(in3);
                      ByteArrayOutputStream bao3 = new ByteArrayOutputStream();
                      bitmapOrg3.compress(Bitmap.CompressFormat.JPEG, 90, bao3);
                      byte [] imagearray3 = bao3.toByteArray();
                      String ba3=Base64.encode(imagearray3);
                  
                      List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);
                  
                      nameValuePairs.add(new BasicNameValuePair("image1",ba1));
                      nameValuePairs.add(new BasicNameValuePair("image2",ba2));
                      nameValuePairs.add(new BasicNameValuePair("image3",ba3));
                  
                      try{
                          HttpClient httpclient = new DefaultHttpClient();
                          HttpPost httppost = new HttpPost("http://helpdesk.cispl.com/upload_file.php");
                          UrlEncodedFormEntity obj = new UrlEncodedFormEntity(nameValuePairs);
                          obj.setChunked(true);
                          httppost.setEntity(obj);
                          HttpResponse response = httpclient.execute(httppost);
                          HttpEntity entity = response.getEntity();
                          //is = entity.getContent();
                          httpclient.getConnectionManager().shutdown(); 
                      }
                      catch(Exception e){
                          //CommonFunctions.writeLOG(ctx.getClass().toString(), e.toString());
                          //CommonFunctions.showToast(ctx, "Unable to post captured image file: " +
                          //e.toString());
                      }
                  }
                  

                  解決方案

                  Looks like your PHP is correct.

                  On your device use HTTP POST request with MultipartEntity data type. Read more here

                  EDIT

                  Example from my link:

                  You will have to download additional libraries to get MultipartEntity running!

                  1) Download httpcomponents-client-4.1.zip from http://james.apache.org/download.cgi#Apache_Mime4J and add apache-mime4j-0.6.1.jar to your project.

                  2) Download httpcomponents-client-4.1-bin.zip from http://hc.apache.org/downloads.cgi and add httpclient-4.1.jar, httpcore-4.1.jar and httpmime-4.1.jar to your project.

                  3) Use the example code below.

                  
                  
                      private DefaultHttpClient mHttpClient;
                  
                  
                      public ServerCommunication() {
                          HttpParams params = new BasicHttpParams();
                          params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
                          mHttpClient = new DefaultHttpClient(params);
                      }
                  
                  
                      public void uploadUserPhoto(File image1, File image2, File image3) {
                  
                          try {
                  
                              HttpPost httppost = new HttpPost("some url");
                  
                              MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);  
                              multipartEntity.addPart("Title", new StringBody("Title"));
                              multipartEntity.addPart("Nick", new StringBody("Nick"));
                              multipartEntity.addPart("Email", new StringBody("Email"));
                              multipartEntity.addPart("Description", new StringBody(Settings.SHARE.TEXT));
                              multipartEntity.addPart("file1", new FileBody(image1));
                              multipartEntity.addPart("file2", new FileBody(image2));
                              multipartEntity.addPart("file3", new FileBody(image3));
                              httppost.setEntity(multipartEntity);
                  
                              mHttpClient.execute(httppost, new PhotoUploadResponseHandler());
                  
                          } catch (Exception e) {
                              Log.e(ServerCommunication.class.getName(), e.getLocalizedMessage(), e);
                          }
                      }
                  
                      private class PhotoUploadResponseHandler implements ResponseHandler {
                  
                          @Override
                          public Object handleResponse(HttpResponse response)
                                  throws ClientProtocolException, IOException {
                  
                              HttpEntity r_entity = response.getEntity();
                              String responseString = EntityUtils.toString(r_entity);
                              Log.d("UPLOAD", responseString);
                  
                              return null;
                          }
                  
                      }
                  
                  
                  
                  

                  這篇關(guān)于從android在php服務(wù)器上上傳多個(gè)圖像的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  enable SOAP on PHP(在 PHP 上啟用 SOAP)
                  Get received XML from PHP SOAP Server(從 PHP SOAP 服務(wù)器獲取接收到的 XML)
                  not a valid AllXsd value(不是有效的 AllXsd 值)
                  PHP SoapClient: SoapFault exception Could not connect to host(PHP SoapClient:SoapFault 異常無(wú)法連接到主機(jī))
                  Implementation of P_SHA1 algorithm in PHP(PHP中P_SHA1算法的實(shí)現(xiàn))
                  Sending a byte array from PHP to WCF(將字節(jié)數(shù)組從 PHP 發(fā)送到 WCF)

                      1. <small id='Y2STK'></small><noframes id='Y2STK'>

                          <tbody id='Y2STK'></tbody>
                        • <bdo id='Y2STK'></bdo><ul id='Y2STK'></ul>
                          <tfoot id='Y2STK'></tfoot>
                            <legend id='Y2STK'><style id='Y2STK'><dir id='Y2STK'><q id='Y2STK'></q></dir></style></legend>

                            <i id='Y2STK'><tr id='Y2STK'><dt id='Y2STK'><q id='Y2STK'><span id='Y2STK'><b id='Y2STK'><form id='Y2STK'><ins id='Y2STK'></ins><ul id='Y2STK'></ul><sub id='Y2STK'></sub></form><legend id='Y2STK'></legend><bdo id='Y2STK'><pre id='Y2STK'><center id='Y2STK'></center></pre></bdo></b><th id='Y2STK'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Y2STK'><tfoot id='Y2STK'></tfoot><dl id='Y2STK'><fieldset id='Y2STK'></fieldset></dl></div>
                          • 主站蜘蛛池模板: 亚洲精品成人在线 | 男女免费在线观看视频 | 毛片网站在线观看 | 91久操视频 | yiren22 亚洲综合 | 国产乱码精品1区2区3区 | 精品欧美一区二区精品久久久 | 欧美精品一区二区在线观看 | 午夜网站视频 | 一区二区三区四区在线视频 | 日韩成人av在线 | 国产yw851.c免费观看网站 | 久久成人精品 | 亚洲视频欧美视频 | 欧美一区二区三 | 欧美一区二区三区在线观看 | 在线视频一区二区三区 | 国产毛片在线看 | 免费人成激情视频在线观看冫 | 国产一级黄色网 | 91精品国产自产在线老师啪 | 精品96久久久久久中文字幕无 | 一区二区三区免费在线观看 | 免费一区二区三区 | av手机在线 | 91网视频 | 国产乱人伦 | 久久综合一区 | 一区二区三区四区五区在线视频 | 国产激情片在线观看 | 啪啪免费网 | 在线日韩欧美 | 亚洲色在线视频 | 国产亚洲精品精品国产亚洲综合 | 岛国精品 | 精品麻豆剧传媒av国产九九九 | 91久久久久久久久久久久久 | www.久久 | 亚洲精品视频在线观看视频 | 台湾av在线| 日韩一区二区成人 |