- // This is the 1st Item iteration let's open output file and allocate necessary resources
- if (appCtx == NULL) {
- // Create an application specific context
- appCtx = calloc (1, sizeof(appPostCtx)); // May place anything here until post->completeCB handle resources liberation
- appCtx->path = strdup (filepath);
-
- // attach application to postHandle
- postHandle->ctx = (void*) appCtx; // May place anything here until post->completeCB handle resources liberation
-
- // Allocate an application specific handle to this post
- strncpy (filepath, request->config->sessiondir, sizeof(filepath));
- strncat (filepath, "/", sizeof(filepath));
- strncat (filepath, item->filename, sizeof(filepath));
+// PostForm callback is called multiple times (one or each key within form, or once per file buffer)
+// When file has been fully uploaded call is call with item==NULL
+STATIC json_object* UploadImage (AFB_request *request, AFB_PostItem *item) {
+
+ // note if directory is relative it will be prefixed by request->config->sessiondir
+ char *destination = "images";