how to upload more than one image to server(mysql database) using php and android

前端 未结 2 2013
无人共我
无人共我 2021-01-15 02:39

I am referring this code in my project..code snippet. Here i can able to upload one image succesfully..Now i have to upload more than one image..How can i do that one..I di

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-15 03:01

    You can use $id = uniqid(); in order to get different id for the images.

    In your java code, change private int PICK_IMAGE_REQUEST1 = 1; to private int PICK_IMAGE_REQUEST1 = 2;

     @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
            switch (requestCode) {
                case PICK_IMAGE_REQUEST:
                    if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK & null != data) {
                       Uri filePath = data.getData();
        try {
            bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath);
            //bitmap1 = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath);
            imageView.setImageBitmap(bitmap);
        } catch (IOException e) {
            e.printStackTrace();
        }
                    }
    
                    break;
    
                case PICK_IMAGE_REQUEST1:
                    if (requestCode == PICK_IMAGE_REQUEST1 && resultCode == RESULT_OK) {
                        Uri filePath = data.getData();
        try {
            //bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath);
            bitmap1 = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath);
            //imageView.setImageBitmap(bitmap);
            imageView1.setImageBitmap(bitmap1);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
        }
    

提交回复
热议问题