使用setRequestProperty发送句子

时间:2017-09-29 14:15:59

标签: java php android

我正在从我的Android应用程序向PHP服务器发送图像和一些文本,我正在使用此代码执行此操作:

            ...
            URL url = new URL("http://example.com/upload.php");

            httpURLConnection = (HttpURLConnection) url.openConnection();
            httpURLConnection.setDoInput(true);
            httpURLConnection.setDoOutput(true);
            httpURLConnection.setUseCaches(false);
            httpURLConnection.setRequestMethod("POST");
            httpURLConnection.setRequestProperty("Connection", "Keep-Alive");
            httpURLConnection.setRequestProperty("ENCTYPE", "multipart/form-data");
            httpURLConnection.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
            httpURLConnection.setRequestProperty("File", imagePath);
            httpURLConnection.setRequestProperty ("Text", someText);
            ...

someText变量是一个单词时,这是有效的,但当它是一个单词之间有空格的句子时,它就不起作用。

为什么?有没有办法让它发挥作用?

0 个答案:

没有答案