Loading array of files from android to $ _FILES
I want to load multiple files from my Android code so that it is available in the $ _FILES array.
The server looks for files as an array. The PHP code on the server looks like
for ($i=0;$i<$NumFiles;$i++){
...
$filename = $_FILES["fileset"]["name"][$i];
$filetype = $_FILES["fileset"]["type"][$i];
$file = curl_image_create($filePath,$filetype,$filename);
...
}
I have files uploaded to file [] (fileSet) for my android code
HttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MILLISEC);
HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);
HttpClient client = new DefaultHttpClient(httpParams);
HttpPost request = new HttpPost(this.apiURL);
MultipartEntityBuilder mpEntity = MultipartEntityBuilder.create();
StringBody numFilesBody = new StringBody("" + fileSet.length, ContentType.TEXT_PLAIN);
mpEntity.addPart("NumFiles", numFilesBody);
for (int i = 0; i < fileSet.length; i++) {
//What should I be doing here to get the $_FILES set up correctly
}
request.setEntity(mpEntity.build());
HttpResponse response = client.execute(request);
I need to set up HTT PRequest so that the server can read the files in $ _Files as an array.
+3
source to share