Index: gli/trunk/src/org/greenstone/gatherer/remote/RemoteGreenstoneServer.java
===================================================================
--- gli/trunk/src/org/greenstone/gatherer/remote/RemoteGreenstoneServer.java	(revision 16098)
+++ gli/trunk/src/org/greenstone/gatherer/remote/RemoteGreenstoneServer.java	(revision 16111)
@@ -55,4 +55,5 @@
 import org.apache.commons.httpclient.HttpStatus;
 
+
 public class RemoteGreenstoneServer
 {
@@ -171,5 +172,4 @@
 	return greenstoneVersion;
     }
-
 
     // ----------------------------------------------------------------------------------------------------
@@ -865,5 +865,5 @@
 	    String zip_file_path = collection_directory_path + zip_file_name;
 	    ZipTools.zipFiles(zip_file_path, collection_directory_path, collection_file_relative_paths);
-
+	    
 	    // Upload the zip file
 	    String upload_collection_file_command = "cmd=upload-collection-file";
@@ -905,5 +905,5 @@
 	    target_collection_directory_relative_path = target_collection_directory_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
 	    progress_bar.setAction("Uploading files into collection...");
-
+	   
 	    String zip_file_name = collection_name + "-" + System.currentTimeMillis() + ".zip";
 	    String zip_file_path = Gatherer.getCollectDirectoryPath() + zip_file_name;
@@ -917,5 +917,5 @@
 		source_file_relative_paths[i] = getPathRelativeToDirectory(source_files[i], base_directory_path);
 	    }
-
+	    
 	    ZipTools.zipFiles(zip_file_path, base_directory_path, source_file_relative_paths);
 
@@ -1271,31 +1271,29 @@
 	//For a remote GS3
 	//GS3 is running on Tomcat, and Tomcat requires a connection timeout to be set up at the client
-	//side while uploading files. As HttpURLConection couldn't set the connection timeout, HttpClient.jar 
+	//side while uploading files. As HttpURLConnection couldn't set the connection timeout, HttpClient.jar 
 	//from Jakarta is applied to solve this problem only for uploading files. 
-	if (Gatherer.GS3){
+	if (Gatherer.GS3) {
+
 	    // Setup the POST method
-	    PostMethod httppost = new PostMethod(upload_cgi);
-		    
+	    PostMethod httppost = new PostMethod(upload_cgi+"?"+cgi_args); // cgi_args: QUERY_STRING on perl server side
+	    		    
 	    // construct the multipartrequest form
 	    String[] cgi_array=cgi_args.split("&");// get parameter-value pairs from cgi_args string
-	    Part[] parts=new Part[cgi_array.length+6];
+	    Part[] parts=new Part[cgi_array.length+5];
 	    
-	    // We insert a dummy value for the first Part. For some reason, the gliserver side doesn't 
-	    // read the first Part (whether it's the file or a CGI argument like the cmd=upload-collection-file)
-	    parts[0]= new StringPart("dummy_arg", "dummy_value");  // unread dummy value
-	    
-	    // find all parameters of cgi-args and add them into Part[]
-	    for (int i=0; i<cgi_array.length;i++) {
-		parts[i+1]=new StringPart(cgi_array[i].substring(0,cgi_array[i].indexOf("=")),cgi_array[i].substring(cgi_array[i].indexOf("=")+1,cgi_array[i].length()));
-	    }
-	    parts[cgi_array.length+1]= new StringPart("un", remote_greenstone_server_authentication.getUserName());
-	    parts[cgi_array.length+2]= new StringPart("pw", new String(remote_greenstone_server_authentication.getPassword()));
-	    parts[cgi_array.length+3]= new StringPart("ts", String.valueOf(System.currentTimeMillis()));
-	    parts[cgi_array.length+4]= new StringPart("site", Configuration.site_name);
 	    // The FilePart: consisting of the (cgi-arg) name and (optional) filename in the Content-Disposition 
 	    // of the POST request Header (see CGI.pm), and the actual zip file itself. It uses the defaults:
 	    // Content-Type: application/octet-stream; charset=ISO-8859-1,Content-Transfer-Encoding: binary
-	    parts[cgi_array.length+5]= new FilePart("uploaded_file", "zipFile", new File(file_path));
-	    
+	    parts[0]= new FilePart("uploaded_file", "zipFile", new File(file_path));
+
+	    parts[1]= new StringPart("un", remote_greenstone_server_authentication.getUserName());
+	    parts[2]= new StringPart("pw", new String(remote_greenstone_server_authentication.getPassword()));
+	    parts[3]= new StringPart("ts", String.valueOf(System.currentTimeMillis()));
+	    parts[4]= new StringPart("site", Configuration.site_name);
+	    // find all parameters of cgi-args and add them into Part[]
+	    for (int i=0; i<cgi_array.length;i++){
+		parts[5+i]=new StringPart(cgi_array[i].substring(0,cgi_array[i].indexOf("=")),cgi_array[i].substring(cgi_array[i].indexOf("=")+1,cgi_array[i].length()));
+	    }
+
 	    // set MultipartRequestEntity on the POST method
 	    httppost.setRequestEntity(new MultipartRequestEntity(parts, httppost.getParams()));
@@ -1304,10 +1302,8 @@
 	    //httppost.getRequestEntity().writeRequest(new FileOutputStream("request.txt", true)); // true: appends
 	    
-
 	    //set up the HttpClient connection
 	    HttpClient client=new HttpClient();	
 	    client.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, false);
 	    client.getParams().setConnectionManagerTimeout(200000); //set the connection timeout
-	    
 	    // get the output of the command from the server
 	    String command_output = ""; 
@@ -1325,5 +1321,5 @@
 		httppost.releaseConnection();
 	    }
-	return command_output;
+	    return command_output;
 	}
 
