Using a Writer (like BufferedWriter) is not appropriate for sending binary files (like images). You need to use the stream classes, or work with conn.getOutputStream() directly.
Ping & DNS - updated with new look and Ping home screen widget
Joined: Oct 23, 2006
Does this mean i have to send the whole HTTP header bytewise? I tried to send only the image with OutputStream and the rest with BufferedWriter, whoever then the whole fileupload seems to get crippled and the php script does not even recognize that a file upload is requested.
You need to use the stream classes, or work with conn.getOutputStream() directly.
Instead of the for loop i am using the following line of code now.
However this doesn't get it to work as well. I guess i have to write the whole HTTP-Request with the same writer/Stream.
So I need to somehow convert my HTTP-Request to a byte array and send it this way?
TY for you help. Sample Code would be much appreciated
Joined: Mar 22, 2005
Indeed, you can't mix using a stream with using a Writer based on that stream.
Instead of implementing all the details myself, I'd use the HttpClient library. There's even an example app that shows how to use it for file upload.