{"record":{"id":"e88b65e05b7a4253","repo":"nopSolutions/nopCommerce","slug":"admin-common-uploadfile","errorCode":null,"errorMessage":"Admin.Common.UploadFile","messagePattern":"Admin\\.Common\\.UploadFile","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"warning","filePath":"src/Presentation/Nop.Web/Areas/Admin/Controllers/PluginController.cs","lineNumber":218,"sourceCode":"        {\n            title = model.FriendlyName,\n            link = model.ConfigurationUrl,\n            parent = await _localizationService.GetResourceAsync(\"Admin.Configuration.Plugins.Local\"),\n            grandParent = string.Empty,\n            rate = -50 //negative rate is set to move plugins to the end of list\n        }).ToListAsync();\n\n        return Json(models);\n    }\n\n    [HttpPost]\n    [CheckPermission(StandardPermission.Configuration.MANAGE_PLUGINS)]\n    public virtual async Task<IActionResult> UploadPluginsAndThemes(IFormFile archivefile)\n    {\n        try\n        {\n            if (archivefile == null || archivefile.Length == 0)\n                throw new NopException(await _localizationService.GetResourceAsync(\"Admin.Common.UploadFile\"));\n\n            var descriptors = await _uploadService.UploadPluginsAndThemesAsync(archivefile);\n            var pluginDescriptors = descriptors.OfType<PluginDescriptor>().ToList();\n            var themeDescriptors = descriptors.OfType<ThemeDescriptor>().ToList();\n            \n            if (pluginDescriptors.Any())\n            {\n                //events\n                await _eventPublisher.PublishAsync(new PluginsUploadedEvent(pluginDescriptors));\n\n                //activity log\n                var activityLogFormat = await _localizationService.GetResourceAsync(\"ActivityLog.UploadNewPlugin\");\n                await _customerActivityService.InsertActivitiesAsync(\"UploadNewPlugin\", pluginDescriptors, descriptor => string.Format(activityLogFormat, descriptor.FriendlyName));\n            }\n\n            if (themeDescriptors.Any())\n            {\n                //events","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Presentation/Nop.Web/Areas/Admin/Controllers/PluginController.cs#L200-L236","documentation":"Thrown in the PluginController UploadPluginsAndThemes action when the uploaded IFormFile (archivefile) is null or has zero length. The message is fetched from the localization resource key 'Admin.Common.UploadFile' (resolved at runtime to a localized 'upload a file' string), so the raw key only appears if the resource is missing. NopException, caught and shown as an error notification.","triggerScenarios":"POST to UploadPluginsAndThemes with no file attached (multipart form missing the archivefile part) or with an empty zero-byte file.","commonSituations":"The admin clicks upload without selecting a file; the file input's name attribute does not match 'archivefile'; the request exceeds upload size limits and the file is dropped before binding; a proxy/CDN strips the multipart body; the uploaded archive is zero bytes from a failed download.","solutions":["Select a non-empty plugin/theme archive (.zip or .nopexport) before clicking upload.","Verify the file input name is exactly 'archivefile' to match the action parameter.","Increase maxRequestLength / maxAllowedContentLength in web.config if large uploads are being dropped.","Check the archive is a valid, non-zero-byte file produced by a correct export/build."],"exampleFix":"// before\nif (archivefile == null || archivefile.Length == 0)\n    throw new NopException(await _localizationService.GetResourceAsync(\"Admin.Common.UploadFile\"));\n\n// after — explicit client-side check + server-side friendly message\n@if (Context.Request.HasFormContentType)\n{\n    <input type=\"file\" name=\"archivefile\" required />\n}","handlingStrategy":"validation","validationCode":"// Before uploading: ensure a non-empty file is attached\nif (archivefile == null || archivefile.Length == 0)\n{\n    _notificationService.ErrorNotification(\"Please select a plugin/theme archive to upload.\");\n    return View();\n}","typeGuard":"bool IsValidUpload(IFormFile f) => f != null && f.Length > 0;","tryCatchPattern":"// The UploadPluginsAndThemes try/catch shows exc.Message (resolved resource); add client-side required file validation.","preventionTips":["Add a client-side required attribute on the file input named 'archivefile'.","Ensure the input name exactly matches the action parameter 'archivefile'.","Raise maxRequestLength/maxAllowedContentLength for large plugin archives.","Verify the archive is a valid non-zero-byte file before uploading."],"tags":["nopcommerce","admin","plugin","upload","validation","iformfile","localization"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}