I\'m trying to upload a image from Android App to a server with a PHP Script. The HTTP Response returns STATUS OK: 200, but the $_FILES[\"upfile\"][\"name\"] returns empty. I`ve
Code looks fine but in your AsyncTask doInBackground Method, change String lineEnd = "rn"; To String lineEnd = "\r\n"; Should work. The backward slashes ensure r, n are not interpreted as letters but as special characters, r- return carriage, and n- new line.
I have the same problem. I described it here. In my case problem is only when I'm trying to send file with content type "multipart/form-data". And I didn't solve it, maybe it deals with php or server, but question is still without answer.
As temporary solution I changed request type to default post type (application/x-www-form-urlencoded) and transfered image as base64 string. Maybe it help.
I've just encountered the same issue. POSTing a file succeeds with a 200 response, but _FILES is empty. I fixed the issue by specifying the Content-Length header. E.g.:
conn.setRequestProperty("Content-Length", Integer.toString(fileInputStream.available()));
Edit: So, when using this, the file appeared in _FILES but with an error code of 3. However, I also had a call to conn.setChunkedStreamingMode(1024);. Removing the Content-Length and the call to setChunkedStreamingMode worked for me, but I'm pretty sure that the empty _FILES is to do with the Content-Length field not being set correctly.