示例#1
0
        public virtual XVar post()
        {
            dynamic info = XVar.Array(), json = null, result = XVar.Array(), upload = XVar.Array();

            upload = XVar.Clone(MVCFunctions.uploadFiles((XVar)(this.options["param_name"])));
            info   = XVar.Clone(XVar.Array());
            foreach (KeyValuePair <XVar, dynamic> uploadedFile in upload.GetEnumerator())
            {
                info.InitAndSetArrayItem(handle_file_upload((XVar)(uploadedFile.Value), (XVar)(uploadedFile.Key)), null);
            }
            MVCFunctions.Header("Vary", "Accept");
            result = XVar.Clone(XVar.Array());
            foreach (KeyValuePair <XVar, dynamic> file in info.GetEnumerator())
            {
                dynamic userFile = XVar.Array();
                if (XVar.Equals(XVar.Pack(file.Value["error"]), XVar.Pack(false)))
                {
                    dynamic sessionArray = XVar.Array();
                    sessionArray = XVar.Clone(XVar.Array());
                    sessionArray.InitAndSetArrayItem(file.Value, "file");
                    sessionArray.InitAndSetArrayItem(false, "fromDB");
                    sessionArray.InitAndSetArrayItem(false, "deleted");
                    XSession.Session.InitAndSetArrayItem(sessionArray, MVCFunctions.Concat("mupload_", this.formStamp), file.Value["usrName"]);
                }
                userFile = XVar.Clone(buildUserFile((XVar)(file.Value)));
                if (XVar.Pack(!(XVar)(userFile["isImg"])))
                {
                    userFile.InitAndSetArrayItem(true, "isImg");
                    userFile.InitAndSetArrayItem(MVCFunctions.Concat(userFile["url"], "&icon=1"), "thumbnail_url");
                }
                result.InitAndSetArrayItem(userFile, null);
            }
            json = XVar.Clone(MVCFunctions.my_json_encode((XVar)(result)));
            if (XVar.Pack(MVCFunctions.IsJSONAccepted()))
            {
                MVCFunctions.Header("Content-type", "application/json");
            }
            else
            {
                MVCFunctions.Header("Content-type", "text/plain");
            }
            MVCFunctions.Echo(json);
            return(null);
        }