problems in uploading image to mysql server (large images)

hello in my code i am uploading image from android phone to mysql server and database, but there is a problem with large images specially photos captured by the phone camera, when i select the image from gallery the image is not set in the imageView in the layout while other images are set, and in the Logcat i have this:

W/OpenGLRenderer: Bitmap too large to be uploaded into a texture (4128×2322, max=4096×4096)

also when i select image other than images captured from phone camera, which they have smaller size, the message is uploaded with image successfully with the image but it is uloaded twice!!! so please can anyone help me to solve these two problems(twice ulpload+ large images) thank you, this is bellow my code of uploading :

public class send extends AppCompatActivity {
private Button buttonChoose;
private Button buttonUpload;

private ImageView imageView;

private EditText editTextName;
private EditText editTextPhone;
private EditText editTextText;
private Bitmap bitmap;

private int PICK_IMAGE_REQUEST = 1;
private static String host=PathConfig.hostName;
private String UPLOAD_URL ="http://"+host+"/upload.php";

private String KEY_IMAGE = "image";
private String KEY_NAME = "name";
private String KEY_PHONE = "phone";
private String KEY_TEXT = "text";
protected void onCreate(Bundle savedInstanceState) {
    Toolbar toolbar = (Toolbar) findViewById(;

    getSupportActionBar().setDisplayHomeAsUpEnabled(true); // setting the back arrow in the toolbar
   // getSupportActionBar().setDisplayShowHomeEnabled(true);
    setTitle("إرسال شكوى أو إقتراح");

    buttonChoose = (Button) findViewById(;
    buttonUpload = (Button) findViewById(;

    editTextName = (EditText) findViewById(;
    editTextPhone= (EditText) findViewById(;
    editTextText= (EditText) findViewById(;
    imageView  = (ImageView) findViewById(;

    buttonChoose.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
    buttonUpload.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

public String getStringImage(Bitmap bmp){
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    byte[] imageBytes = baos.toByteArray();
    String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
    return encodedImage;

private void uploadImage() {
    final String name = editTextName.getText().toString().trim();
    final  String phone = editTextPhone.getText().toString().trim();
    final String text = editTextText.getText().toString().trim();

    if (name.matches("") || phone.matches("") || text.matches("")) {
        Toast.makeText(this, " عذرا, لا يمكن ترك حقول فارغة", Toast.LENGTH_SHORT).show();

    } else {
        //Showing the progress dialog
        final ProgressDialog loading =, "جاري الإرسال...", "الرجاء الإنتظار...", false, false);
        StringRequest stringRequest = new StringRequest(Request.Method.POST, UPLOAD_URL,
                new Response.Listener<String>() {
                    public void onResponse(String s) {
                        //Disimissing the progress dialog
                        //Showing toast message of the response
                        Toast.makeText(send.this, s, Toast.LENGTH_LONG).show();
                new Response.ErrorListener() {
                    public void onErrorResponse(VolleyError volleyError) {
                        //Dismissing the progress dialog

                        if (volleyError != null) {
                            Log.e(" Upload error ", "Volley " + volleyError.getMessage().toString());
                            //Showing toast
                            Toast.makeText(send.this, volleyError.getMessage().toString(), Toast.LENGTH_LONG).show();
                }) {
            protected Map<String, String> getParams() throws AuthFailureError {
                //Converting Bitmap to String
                String image = getStringImage(bitmap);

                //Getting Image Name

                //Creating parameters
                Map<String, String> params = new HashMap<String, String>();

                //Adding parameters
                params.put(KEY_IMAGE, image);
                params.put(KEY_NAME, name);
                params.put(KEY_PHONE, phone);
                params.put(KEY_TEXT, text);

                //returning parameters
                return params;

        //Creating a Request Queue
        RequestQueue requestQueue = Volley.newRequestQueue(this);

        //Adding request to the queue
private void showFileChooser() {
    Intent intent = new Intent();
    startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {
        Uri filePath = data.getData();
        try {
            //Getting the Bitmap from Gallery
            bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath);
            //Setting the Bitmap to ImageView
        } catch (IOException e) {
public boolean onSupportNavigateUp() {
    return true;