Android:向PHP服务器发送位图会使应用程序崩溃

I want to send an image to the server by converting it to string.
Here is my code for conversion:

public String baseTo64 (Bitmap bitmapImage){
        String imageString = null;
            try {

                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, baos); 
                byte[] b = baos.toByteArray();
                imageString = Base64.encodeToString(b, Base64.DEFAULT);

            } catch (Exception e) {
                e.printStackTrace();
            }

     return imageString;
}

I use AyncTask to send the string along with other strings.

class SubmitReport extends AsyncTask<String, String, String> {

        protected String doInBackground(String... args) {

            String image = baseTo64(bitmapImage);
            String desc =  text2.getText().toString();
            r.setType(rg.indexOfChild(findViewById(rg.getCheckedRadioButtonId())));
            String type = r.getType();
            String latitude = String.valueOf(r.getLati());
            String longitude = String.valueOf(r.getLongi());
            String dateH = r.getStringDate();

            // Building Parameters
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("image", image));
            params.add(new BasicNameValuePair("desc", desc));
            params.add(new BasicNameValuePair("type", type));
            params.add(new BasicNameValuePair("latitude", latitude));
            params.add(new BasicNameValuePair("longitude", longitude));
            params.add(new BasicNameValuePair("dateH", dateH));

            // getting JSON Object
            // Note that create product url accepts POST method
            JSONObject json = jsonParser.makeHttpRequest(url_submit_report, "POST", params);

            // check log cat fro response
            Log.d("Create Response", json.toString());

            // check for success tag
            try {
                int success = json.getInt(TAG_SUCCESS);

                if (success == 1) {
                    // success

                    Log.d("SUCCESS", json.toString());

                    // closing this screen
                   // finish();
                } else {
                    // failed
                    Log.d("FAILED", json.toString());

                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }


    }

My app can successfully send data to server without including the image.
But if I call baseTo64 inside the AsynTask, it crashes. Is this because of too much memory used? I think the returned string is so large to be sent to the server because when I try to use baseTo64 method and display it via toast with only its first 5 characters, it did display the characters.

If that's the case, what will I do to prevent/avoid this? Please help.

07-24 13:32:47.836  26033-27529/com.example.jay.curloc E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #3
    Process: com.example.jay.curloc, PID: 26033
    java.lang.RuntimeException: An error occured while executing doInBackground()
            at android.os.AsyncTask$3.done(AsyncTask.java:300)
            at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
            at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
            at java.util.concurrent.FutureTask.run(FutureTask.java:242)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)
     Caused by: java.lang.NullPointerException
            at com.example.jay.curloc.ReportIncident$SubmitReport.doInBackground(ReportIncident.java:455)
            at com.example.jay.curloc.ReportIncident$SubmitReport.doInBackground(ReportIncident.java:417)
            at android.os.AsyncTask$2.call(AsyncTask.java:288)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)

Add null check like bellow code .

if(fileUri!=null)
{

     // do all relevant part here. 
}