public virtual XVar handle_file_upload(dynamic _param_uploadedFile, dynamic _param_index) { #region pass-by-value parameters dynamic uploadedFile = XVar.Clone(_param_uploadedFile); dynamic index = XVar.Clone(_param_index); #endregion dynamic file = XVar.Array(), fileInfo = null, name = null, path_parts = XVar.Array(), size = null, tmpName = null, uploadDir = null, uploadDirRelative = null, var_error = null, var_type = null; tmpName = XVar.Clone(uploadedFile["tmp_name"]); name = XVar.Clone(uploadedFile["name"]); size = XVar.Clone(uploadedFile["size"]); var_type = XVar.Clone(uploadedFile["type"]); var_error = XVar.Clone(uploadedFile["error"]); fileInfo = XVar.Clone(new XVar("name", name, "size", MVCFunctions.intval((XVar)(size)), "type", var_type, "isThumbnail", false)); uploadDir = XVar.Clone(this.pSet.getFinalUploadFolder((XVar)(this.field), (XVar)(fileInfo))); uploadDirRelative = XVar.Clone(this.pSet.getUploadFolder((XVar)(this.field), (XVar)(fileInfo))); file = XVar.Clone(XVar.Array()); file.InitAndSetArrayItem(false, "error"); file.InitAndSetArrayItem(MVCFunctions.trim_file_name((XVar)(name), (XVar)(var_type), (XVar)(index), this), "name"); file.InitAndSetArrayItem(file["name"], "usrName"); file.InitAndSetArrayItem(MVCFunctions.intval((XVar)(size)), "size"); switch (((XVar)var_type).ToString()) { case "image/png": case "image/x-png": file.InitAndSetArrayItem("image/png", "type"); break; case "image/jpeg": case "image/pjpeg": file.InitAndSetArrayItem("image/jpeg", "type"); break; default: file.InitAndSetArrayItem(var_type, "type"); break; } path_parts = XVar.Clone(pathinfo_local((XVar)(name))); if (file["type"] == "") { file.InitAndSetArrayItem(CommonFunctions.getContentTypeByExtension((XVar)(path_parts["extension"])), "type"); } file.InitAndSetArrayItem(false, "isImg"); file.InitAndSetArrayItem("", "thumbnail"); if (XVar.Pack(this.pSet.isMakeDirectoryNeeded((XVar)(this.field)))) { if (XVar.Pack(!(XVar)(MVCFunctions.makeSurePathExists((XVar)(uploadDir))))) { file.InitAndSetArrayItem("No existe el envío de carpetas", "error"); return(file); } } else { if (XVar.Pack(!(XVar)(MVCFunctions.is_dir((XVar)(uploadDir))))) { file.InitAndSetArrayItem("No existe el envío de carpetas", "error"); return(file); } } if (XVar.Pack(validate((XVar)(uploadedFile), (XVar)(file), (XVar)(var_error), (XVar)(size), (XVar)(index), (XVar)(uploadDir)))) { dynamic file_path = null, file_size = null; file.InitAndSetArrayItem(CommonFunctions.CheckImageExtension((XVar)(tmpName)) != false, "isImg"); handle_form_data((XVar)(file), (XVar)(index)); file.InitAndSetArrayItem(tempnam_sfx((XVar)(uploadDir), (XVar)(path_parts["filename"]), (XVar)(path_parts["extension"])), "name"); file_path = XVar.Clone(MVCFunctions.Concat(uploadDir, file["name"])); MVCFunctions.clearstatcache(); MVCFunctions.upload_File((XVar)(uploadedFile), (XVar)(file_path)); file_size = XVar.Clone(MVCFunctions.filesize((XVar)(file_path))); if (XVar.Pack(this.options["resizeOnUpload"])) { dynamic new_file_name = null, tempOptions = null; tempOptions = XVar.Clone(new XVar("max_width", this.options["max_width"], "max_height", this.options["max_width"])); new_file_name = XVar.Clone(tempnam_sfx((XVar)(uploadDir), (XVar)(path_parts["filename"]), (XVar)(path_parts["extension"]))); if (XVar.Pack(create_scaled_image((XVar)(MVCFunctions.Concat(uploadDir, file["name"])), (XVar)(uploadDir), (XVar)(new_file_name), (XVar)(tempOptions), (XVar)(file), new XVar(false), (XVar)(uploadDirRelative), (XVar)(uploadedFile)))) { MVCFunctions.unlink((XVar)(file_path)); file.InitAndSetArrayItem(new_file_name, "name"); file_path = XVar.Clone(MVCFunctions.Concat(uploadDir, new_file_name)); file_size = XVar.Clone(MVCFunctions.filesize((XVar)(file_path))); } } if (XVar.Equals(XVar.Pack(file_size), XVar.Pack(file["size"]))) { file.InitAndSetArrayItem(MVCFunctions.Concat(uploadDir, MVCFunctions.RawUrlEncode((XVar)(file["name"]))), "url"); foreach (KeyValuePair <XVar, dynamic> options in this.options["image_versions"].GetEnumerator()) { dynamic fileInfoThimbnail = null, thumbUploadDir = null, thumbUploadDirRelative = null, thumbnail_name = null; fileInfoThimbnail = XVar.Clone(new XVar("name", name, "size", MVCFunctions.intval((XVar)(size)), "type", var_type, "isThumbnail", true)); thumbUploadDir = XVar.Clone(this.pSet.getFinalUploadFolder((XVar)(this.field), (XVar)(fileInfoThimbnail))); thumbUploadDirRelative = XVar.Clone(this.pSet.getUploadFolder((XVar)(this.field), (XVar)(fileInfoThimbnail))); if (XVar.Pack(this.pSet.isMakeDirectoryNeeded((XVar)(this.field)))) { if (XVar.Pack(!(XVar)(MVCFunctions.makeSurePathExists((XVar)(thumbUploadDir))))) { continue; } } thumbnail_name = XVar.Clone(tempnam_sfx((XVar)(thumbUploadDir), (XVar)(MVCFunctions.Concat(options.Value["thumbnailPrefix"], path_parts["filename"])), (XVar)(path_parts["extension"]))); if (XVar.Pack(create_scaled_image((XVar)(MVCFunctions.Concat(uploadDir, file["name"])), (XVar)(thumbUploadDir), (XVar)(thumbnail_name), (XVar)(options.Value), (XVar)(file), new XVar(true), (XVar)(thumbUploadDirRelative), (XVar)(uploadedFile)))) { MVCFunctions.clearstatcache(); file_size = XVar.Clone(MVCFunctions.filesize((XVar)(file_path))); } } } else { MVCFunctions.unlink((XVar)(file_path)); file.InitAndSetArrayItem("abort", "error"); } file.InitAndSetArrayItem(file_size, "size"); file.InitAndSetArrayItem(MVCFunctions.Concat(uploadDirRelative, file["name"]), "name"); set_file_delete_url((XVar)(file)); } return(file); }