src/hg/instinct/hgGeneset/hgGenesets.c 1.14

1.14 2010/02/01 14:58:41 sbenz
Added start of file upload fxn
Index: src/hg/instinct/hgGeneset/hgGenesets.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/hgGeneset/hgGenesets.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -b -B -U 4 -r1.13 -r1.14
--- src/hg/instinct/hgGeneset/hgGenesets.c	31 Jan 2010 02:45:46 -0000	1.13
+++ src/hg/instinct/hgGeneset/hgGenesets.c	1 Feb 2010 14:58:41 -0000	1.14
@@ -1354,8 +1354,39 @@
 if (js)
     hPrintf("%s\n", js->print(js));
 }
 
+void uploadData()
+{
+char *fileContent = NULL;
+char *err = NULL;
+	
+//Filedata
+fileContent = cgiOptionalString(hghFileUpload);
+if(fileContent == NULL)
+	{
+	errAbort("File is required, set into %s.",hghFileUpload);
+	}
+else
+	{
+	if (isNotEmpty(fileContent))
+		{
+		// handle upload in here, set err to something other than null if it fails
+		}
+	if(err)
+		printf("Error: %s\n",err);
+	else
+		{
+		struct json *js = newJson();
+		jsonAddString(js, "uploadData", "success");
+		//jsonAddString(js, "table", newCts->dbTableName);
+		hPrintf("%s", js->print(js));
+		}
+	}
+cartRemove(cart, "Filename");
+cartRemoveLike(cart, "Filedata*");	
+}
+
 void dispatchRoutines()
 /* Look at command variables in cart and figure out which
  * page to draw. */
 {
@@ -1377,8 +1408,10 @@
 else if (sameString(mode, "requestState"))
     requestState();
 else if (sameString(mode, "resetState"))
     resetState();
+else if (sameString(mode, "uploadData"))
+    uploadData();
 else
     errAbort("Incorrect mode = %s", mode);
 
 //cartRemovePrefix(cart, hghPrefix);