Index: trunk/zoo-project/zoo-kernel/zoo_loader.c
===================================================================
--- trunk/zoo-project/zoo-kernel/zoo_loader.c	(revision 330)
+++ trunk/zoo-project/zoo-kernel/zoo_loader.c	(revision 331)
@@ -76,4 +76,5 @@
 #endif
 
+  char *strQuery=strdup(cgiQueryString);
   map* tmpMap=NULL;
 
@@ -107,4 +108,5 @@
 	buffer[cgiContentLength]=0;
 	tmpMap=createMap("request",buffer);
+	fprintf(stderr,"%s\n",tmpMap->value);
       }else{
 	buffer[0]=0;
@@ -141,4 +143,5 @@
   }
   else{
+    dumpMap(tmpMap);
     char **array, **arrayStep;
     if (cgiFormEntries(&array) != cgiFormSuccess) {
@@ -179,5 +182,5 @@
      */
     map* t1=getMap(tmpMap,"request");
-    if(t1!=NULL){
+    if(t1!=NULL && strncasecmp(t1->value,"<",1)==0){
       addToMap(tmpMap,"xrequest",t1->value);
       xmlInitParser();
@@ -281,4 +284,8 @@
       xmlFreeDoc(doc);
       xmlCleanupParser();
+    }else{
+      freeMap(&tmpMap);
+      free(tmpMap);
+      tmpMap=createMap("not_valid","true");
     }
 
@@ -297,12 +304,21 @@
 	token1=strtok_r(NULL,"=",&saveptr1);
       }
-      if(strcasecmp(name,"metapath")==0)
-	addToMap(tmpMap,name,value);
+      addToMap(tmpMap,name,value);
       free(name);
       free(value);
+      name=NULL;
+      value=NULL;
       token=strtok_r(NULL,"&",&saveptr);
     }
     
   }
+
+
+  if(strncasecmp(cgiContentType,"multipart/form-data",19)==0){
+      map* tmp=getMap(tmpMap,"dataInputs");
+      if(tmp!=NULL){
+	addToMap(tmpMap,"dataInputs",strstr(strQuery,"dataInputs=")+11);
+      }
+    }
 
   runRequest(tmpMap);
Index: trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 330)
+++ trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 331)
@@ -742,5 +742,5 @@
 #endif
   int saved_stdout = dup(fileno(stdout));
-    dup2(fileno(stderr),fileno(stdout));
+  dup2(fileno(stderr),fileno(stdout));
   t=getServiceFromFile(tmps1,&s1);
   fflush(stdout);
@@ -1645,5 +1645,5 @@
 	       */
 	      else if(xmlStrncasecmp(cur2->name,BAD_CAST "Title",xmlStrlen(cur2->name))==0 ||
-		 xmlStrncasecmp(cur2->name,BAD_CAST "Abstract",xmlStrlen(cur2->name))==0){
+		      xmlStrncasecmp(cur2->name,BAD_CAST "Abstract",xmlStrlen(cur2->name))==0){
 		xmlChar *val=
 		  xmlNodeListGetString(doc,cur2->xmlChildrenNode,1);
@@ -1733,4 +1733,59 @@
   }
 
+  maps* tmpReqI=request_input_real_format;
+  while(tmpReqI!=NULL){
+    char name[1024];
+    if(getMap(tmpReqI->content,"isFile")!=NULL){
+      if (cgiFormFileName(tmpReqI->name, name, sizeof(name)) == cgiFormSuccess) {
+	int BufferLen=1024;
+	cgiFilePtr file;
+	int targetFile;
+	mode_t mode;
+	char storageNameOnServer[2048];
+	char fileNameOnServer[64];
+	char contentType[1024];
+	char buffer[BufferLen];
+	char *tmpStr=NULL;
+	int size;
+	int got,t;
+	map *path=getMapFromMaps(m,"main","tmpPath");
+	cgiFormFileSize(tmpReqI->name, &size);
+	cgiFormFileContentType(tmpReqI->name, contentType, sizeof(contentType));
+	if (cgiFormFileOpen(tmpReqI->name, &file) == cgiFormSuccess) {
+	  t=-1;
+	  while(1){
+	    tmpStr=strstr(name+t+1,"\\");
+	    if(NULL==tmpStr)
+	      tmpStr=strstr(name+t+1,"/");
+	    if(NULL!=tmpStr)
+	      t=(int)(tmpStr-name);
+	    else
+	      break;
+	  }
+	  strcpy(fileNameOnServer,name+t+1);
+	  
+	  sprintf(storageNameOnServer,"%s/%s",path->value,fileNameOnServer);
+	  fprintf(stderr,"Name on server %s\n",storageNameOnServer);
+	  fprintf(stderr,"fileNameOnServer: %s\n",fileNameOnServer);
+	  mode=S_IRWXU|S_IRGRP|S_IROTH;
+	  targetFile = open (storageNameOnServer,O_RDWR|O_CREAT|O_TRUNC,mode);
+	  if(targetFile<0){
+	    fprintf(stderr,"could not create the new file,%s\n",fileNameOnServer);	    
+	  }else{
+	    while (cgiFormFileRead(file, buffer, BufferLen, &got) ==cgiFormSuccess){
+	      if(got>0)
+		write(targetFile,buffer,got);
+	    }
+	  }
+	  addToMap(tmpReqI->content,"lref",storageNameOnServer);
+	  cgiFormFileClose(file);
+	  close(targetFile);
+	  fprintf(stderr,"File \"%s\" has been uploaded",fileNameOnServer);
+	}
+      }
+    }
+    tmpReqI=tmpReqI->next;
+  }
+
   ensureDecodedBase64(&request_input_real_format);
 
@@ -1862,5 +1917,5 @@
   char *cgiSidL=NULL;
   if(getenv("CGISID")!=NULL)
-	addToMap(request_inputs,"cgiSid",getenv("CGISID"));
+    addToMap(request_inputs,"cgiSid",getenv("CGISID"));
   map* test1=getMap(request_inputs,"cgiSid");
   if(test1!=NULL){
@@ -1959,6 +2014,4 @@
 #ifdef DEBUG
   dumpMaps(request_output_real_format);
-  fprintf(stderr,"Function loaded and returned %d\n",*eres);
-  fflush(stderr);
 #endif
   if(eres!=-1)
