Ⅰ 如何用安卓手機上傳圖片到百度上,就是在百度圖片上可以查到!!
- 把照片上傳到網路空間,網友即可在網路圖片里搜索照片關鍵詞看到。 
 進入網路的圖片image..com/→右上方「登錄」→登錄以後右上方「我的相冊」→右上方「上傳照片」,按提示把照片上傳到網路空間即可。
 或直接點擊此頁面右上方「空間」→左邊「相冊」→「上傳照片」
 提示:照片上傳到相冊後不會立刻搜索到,需要過幾天。快登錄空間上傳圖片吧
- 可以把圖片上傳到網路空間相冊,然後在相冊里點擊查看該圖片,右鍵單擊該圖片→屬性,在裡面復制下圖片地址。在問題補充里發出圖片地址,網友點開地址就可以看到。 
Ⅱ 安卓如何在後台上傳圖片等資料
public class EX08_11 extends Activity  
{  
  /* 變數聲明 
   * newName:上傳後在伺服器上的文件名稱 
   * uploadFile:要上傳的文件路徑 
   * actionUrl:伺服器對應的程序路徑 */  
//  private String newName="345444.jpg";  
  private String uploadFile="/sdcard/345444.jpg";  
  private String actionUrl="http://*********/upload.PHP";  
  private TextView mText1;  
  private TextView mText2;  
  private Button mButton;  
    
  @Override  
  public void onCreate(Bundle savedInstanceState)  
  {  
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.main);  
  
    mText1 = (TextView) findViewById(R.id.myText2);  
    mText1.setText("文件路徑:/n"+uploadFile);  
      
    mText2 = (TextView) findViewById(R.id.myText3);  
    mText2.setText("上傳網址:/n"+actionUrl);  
    /* 設定mButton的onClick事件處理 */      
    mButton = (Button) findViewById(R.id.myButton);  
    mButton.setOnClickListener(new View.OnClickListener()  
    {  
      public void onClick(View v)  
      {  
        uploadFile();  
      }  
    });  
  }  
    
  /* 上傳文件吹Server的method */  
  private void uploadFile()  
  {  
//    String end = "/r/n";  
//    String twoHyphens = "--";  
    String boundary = "*****";  
    try  
    {  
      URL url =new URL(actionUrl);  
      HttpURLConnection con=(HttpURLConnection)url.openConnection();  
      /* 允許Input、Output,不使用Cache */  
//      con.setReadTimeout(5 * 1000);   
      con.setDoInput(true);  
      con.setDoOutput(true);  
      con.setUseCaches(false);  
      /* 設定傳送的method=POST */  
      con.setRequestMethod("POST");  
      /* setRequestProperty */  
      con.setRequestProperty("Connection", "Keep-Alive");  
      con.setRequestProperty("Charset", "UTF-8");  
      con.setRequestProperty("enctype",  
                         "multipart/form-data;boundary="+boundary);  
      /* 設定DataOutputStream */  
      DataOutputStream ds =   
        new DataOutputStream(con.getOutputStream());  
      /*ds.writeBytes(twoHyphens + boundary + end); 
      ds.writeBytes("Content-Disposition: form-data; " + 
                    "name=/"file1/";filename=/"" + 
                    newName +"/"" + end); 
      ds.writeBytes(end);  */   
  
      /* 取得文件的FileInputStream */  
      FileInputStream fStream = new FileInputStream(uploadFile);  
      /* 設定每次寫入1024bytes */  
      int bufferSize = 1024;  
      byte[] buffer = new byte[bufferSize];  
  
      int length = -1;  
      /* 從文件讀取數據到緩沖區 */  
      while((length = fStream.read(buffer)) != -1)  
      {  
        /* 將數據寫入DataOutputStream中 */  
        ds.write(buffer, 0, length);  
      }  
//      ds.writeBytes(end);  
//      ds.writeBytes(twoHyphens + boundary + twoHyphens + end);  
  
      /* close streams */  
      fStream.close();  
      ds.flush();  
/* 取得Response內容 */  
      InputStream is = con.getInputStream();  
      int ch;  
      StringBuffer b =new StringBuffer();  
      while( ( ch = is.read() ) != -1 )  
      {  
        b.append( (char)ch );  
      }  
      /* 將Response顯示於Dialog */  
      showDialog(b.toString().trim());  
      /* 關閉DataOutputStream */  
      ds.close();  
    }  
    catch(Exception e)  
    {  
      showDialog(""+e);  
    }  
  }  
    
  /* 顯示Dialog的method */  
  private void showDialog(String mess)  
  {  
    new AlertDialog.Builder(EX08_11.this).setTitle("Message")  
     .setMessage(mess)  
     .setNegativeButton("確定",new DialogInterface.OnClickListener()  
     {  
       public void onClick(DialogInterface dialog, int which)  
       {            
       }  
     })  
     .show();  
  }  
}  
PHP代碼
[php] view plain 
$data = file_get_contents('php://input');  
$handle = fopen($_SERVER['DOCUMENT_ROOT'].'/image/345444.jpg', 'w');  
if ($handle)  
{  
 fwrite($handle,$data);  
 fclose($handle);  
 echo "success";  
}
Ⅲ 安卓手機怎麼往電腦上傳照片
用數據線的話可以直接在電腦上打開手機存儲找到DCIM文件夾,裡面就是相機的照片。無線的話可以連接電腦藍牙或者直接在電腦上登錄微信,在手機微信上發到文件助手就可以了。
Ⅳ 如何把本地照片上傳至安卓系統
有個usb存儲,我的就有,不過我的是4.0,實在不行你就打開usb調試,用360手機助手管理文件
Ⅳ 安卓版收錄優美圖片如何上傳圖片
點擊網站的上傳圖片鏈接,,,就可以傳圖片了
Ⅵ android怎樣上傳圖片到伺服器
界面很簡單,點擊 【選擇圖片】,從圖庫里選擇圖片,顯示到下面的imageview里,點擊上傳,就會上傳到指定的伺服器
布局文件:
 
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
   
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <Button   
    android:layout_width="fill_parent"  
    android:layout_height="wrap_content"  
    android:text="選擇圖片" 
    android:id="@+id/selectImage" 
    /> 
    <Button   
    android:layout_width="fill_parent"  
    android:layout_height="wrap_content"  
    android:text="上傳圖片" 
    android:id="@+id/uploadImage" 
    /> 
     <ImageView   
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:id="@+id/imageView" 
    /> 
</LinearLayout>
Upload Activity:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
   
public class Upload extends Activity implements OnClickListener {
    private static String requestURL = "http://192.168.1.212:8011/pd/upload/fileUpload.do";
    private Button selectImage, uploadImage;
    private ImageView imageView;
 
    private String picPath = null;
 
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.upload);
 
        selectImage = (Button) this.findViewById(R.id.selectImage);
        uploadImage = (Button) this.findViewById(R.id.uploadImage);
        selectImage.setOnClickListener(this);
        uploadImage.setOnClickListener(this);
 
        imageView = (ImageView) this.findViewById(R.id.imageView);
 
    }
 
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.selectImage:
            /***
             * 這個是調用android內置的intent,來過濾圖片文件 ,同時也可以過濾其他的
             */
            Intent intent = new Intent();
            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(intent, 1);
            break;
        case R.id.uploadImage:
            if (picPath == null) {
 
                Toast.makeText(Upload.this, "請選擇圖片!", 1000).show();
            } else {
                final File file = new File(picPath);
 
                if (file != null) {
                    String request = UploadUtil.uploadFile(file, requestURL);
                    uploadImage.setText(request);
                }
            }
            break;
        default:
            break;
        }
    }
 
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == Activity.RESULT_OK) {
            /**
             * 當選擇的圖片不為空的話,在獲取到圖片的途徑
             */
            Uri uri = data.getData();
            Log.e(TAG, "uri = " + uri);
            try {
                String[] pojo = { MediaStore.Images.Media.DATA };
 
                Cursor cursor = managedQuery(uri, pojo, null, null, null);
                if (cursor != null) {
                    ContentResolver cr = this.getContentResolver();
                    int colunm_index = cursor
                            .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
                    cursor.moveToFirst();
                    String path = cursor.getString(colunm_index);
                    /***
                     * 這里加這樣一個判斷主要是為了第三方的軟體選擇,比如:使用第三方的文件管理器的話,你選擇的文件就不一定是圖片了,
                     * 這樣的話,我們判斷文件的後綴名 如果是圖片格式的話,那麼才可以
                     */
                    if (path.endsWith("jpg") || path.endsWith("png")) {
                        picPath = path;
                        Bitmap bitmap = BitmapFactory.decodeStream(cr
                                .openInputStream(uri));
                        imageView.setImageBitmap(bitmap);
                    } else {
                        alert();
                    }
                } else {
                    alert();
                }
 
            } catch (Exception e) {
            }
        }
 
        super.onActivityResult(requestCode, resultCode, data);
    }
 
    private void alert() {
        Dialog dialog = new AlertDialog.Builder(this).setTitle("提示")
                .setMessage("您選擇的不是有效的圖片")
                .setPositiveButton("確定", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        picPath = null;
                    }
                }).create();
        dialog.show();
    }
 
}
這個才是重點 UploadUtil:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
   
public class UploadUtil {
    private static final String TAG = "uploadFile";
    private static final int TIME_OUT = 10 * 1000; // 超時時間
    private static final String CHARSET = "utf-8"; // 設置編碼
    /**
     * 上傳文件到伺服器
     * @param file 需要上傳的文件
     * @param RequestURL 請求的rul
     * @return 返回響應的內容
     */
    public static int uploadFile(File file, String RequestURL) {
        int res=0;
        String result = null;
        String BOUNDARY = UUID.randomUUID().toString(); // 邊界標識 隨機生成
        String PREFIX = "--", LINE_END = "\r\n";
        String CONTENT_TYPE = "multipart/form-data"; // 內容類型
 
        try {
            URL url = new URL(RequestURL);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setReadTimeout(TIME_OUT);
            conn.setConnectTimeout(TIME_OUT);
            conn.setDoInput(true); // 允許輸入流
            conn.setDoOutput(true); // 允許輸出流
            conn.setUseCaches(false); // 不允許使用緩存
            conn.setRequestMethod("POST"); // 請求方式
            conn.setRequestProperty("Charset", CHARSET); // 設置編碼
            conn.setRequestProperty("connection", "keep-alive");
            conn.setRequestProperty("Content-Type", CONTENT_TYPE + ";boundary="+ BOUNDARY);
 
            if (file != null) {
                /**
                 * 當文件不為空時執行上傳
                 */
                DataOutputStream dos = new DataOutputStream(conn.getOutputStream());
                StringBuffer sb = new StringBuffer();
                sb.append(PREFIX);
                sb.append(BOUNDARY);
                sb.append(LINE_END);
                /**
                 * 這里重點注意: name裡面的值為伺服器端需要key 只有這個key 才可以得到對應的文件
                 * filename是文件的名字,包含後綴名
                 */
 
                sb.append("Content-Disposition: form-data; name=\"file\"; filename=\""
                        + file.getName() + "\"" + LINE_END);
                sb.append("Content-Type: application/octet-stream; charset="
                        + CHARSET + LINE_END);
                sb.append(LINE_END);
                dos.write(sb.toString().getBytes());
                InputStream is = new FileInputStream(file);
                byte[] bytes = new byte[1024];
                int len = 0;
                while ((len = is.read(bytes)) != -1) {
                    dos.write(bytes, 0, len);
                }
                is.close();
                dos.write(LINE_END.getBytes());
                byte[] end_data = (PREFIX + BOUNDARY + PREFIX + LINE_END)
                        .getBytes();
                dos.write(end_data);
                dos.flush();
                /**
                 * 獲取響應碼 200=成功 當響應成功,獲取響應的流
                 */
                 res = conn.getResponseCode();
                Log.e(TAG, "response code:" + res);
                if (res == 200) {
                    Log.e(TAG, "request success");
                    InputStream input = conn.getInputStream();
                    StringBuffer sb1 = new StringBuffer();
                    int ss;
                    while ((ss = input.read()) != -1) {
                        sb1.append((char) ss);
                    }
                    result = sb1.toString();
                    Log.e(TAG, "result : " + result);
                } else {
                    Log.e(TAG, "request error");
                }
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return res;
    }
}
