0

I am using a java.net.URL.openConnection() to upload 2 text files to my server (Android to PHP). I am using a similar code to this post. I can get one file uploaded fine but can not figure out how to structure the code for two file. I believe my problem is related to this code.

dos.writeBytes(twoHyphens + boundary + lineEnd); 
dos.writeBytes("Content-Disposition: form-data; name='uploaded_file';filename='" + fileName1 + "'" + lineEnd);
dos.writeBytes("Content-Disposition: form-data; name='uploaded_file2';filename='" + fileName2 + "'" + lineEnd);
dos.writeBytes(lineEnd);
3
  • So in short, you wish to upload 2 or more than two files from your android app. M I right ? Commented Aug 11, 2015 at 17:20
  • Yes - upload two files from my android app Commented Aug 11, 2015 at 17:41
  • I tried using only one dos.writeBytes("Content-Disposition: form-data... line, adding my two files names to a string array, and looping thru the String array uploadFile(filename) but still only one file gets uploaded. Commented Aug 11, 2015 at 18:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.