nopSolutions/nopCommerce · warning · NopException

Admin.Common.UploadFile

Error message

Admin.Common.UploadFile

What it means

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.

Source

Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/PluginController.cs:218

        {
            title = model.FriendlyName,
            link = model.ConfigurationUrl,
            parent = await _localizationService.GetResourceAsync("Admin.Configuration.Plugins.Local"),
            grandParent = string.Empty,
            rate = -50 //negative rate is set to move plugins to the end of list
        }).ToListAsync();

        return Json(models);
    }

    [HttpPost]
    [CheckPermission(StandardPermission.Configuration.MANAGE_PLUGINS)]
    public virtual async Task<IActionResult> UploadPluginsAndThemes(IFormFile archivefile)
    {
        try
        {
            if (archivefile == null || archivefile.Length == 0)
                throw new NopException(await _localizationService.GetResourceAsync("Admin.Common.UploadFile"));

            var descriptors = await _uploadService.UploadPluginsAndThemesAsync(archivefile);
            var pluginDescriptors = descriptors.OfType<PluginDescriptor>().ToList();
            var themeDescriptors = descriptors.OfType<ThemeDescriptor>().ToList();
            
            if (pluginDescriptors.Any())
            {
                //events
                await _eventPublisher.PublishAsync(new PluginsUploadedEvent(pluginDescriptors));

                //activity log
                var activityLogFormat = await _localizationService.GetResourceAsync("ActivityLog.UploadNewPlugin");
                await _customerActivityService.InsertActivitiesAsync("UploadNewPlugin", pluginDescriptors, descriptor => string.Format(activityLogFormat, descriptor.FriendlyName));
            }

            if (themeDescriptors.Any())
            {
                //events

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Select a non-empty plugin/theme archive (.zip or .nopexport) before clicking upload.
  2. Verify the file input name is exactly 'archivefile' to match the action parameter.
  3. Increase maxRequestLength / maxAllowedContentLength in web.config if large uploads are being dropped.
  4. Check the archive is a valid, non-zero-byte file produced by a correct export/build.

Example fix

// before
if (archivefile == null || archivefile.Length == 0)
    throw new NopException(await _localizationService.GetResourceAsync("Admin.Common.UploadFile"));

// after — explicit client-side check + server-side friendly message
@if (Context.Request.HasFormContentType)
{
    <input type="file" name="archivefile" required />
}
Defensive patterns

Strategy: validation

Validate before calling

// Before uploading: ensure a non-empty file is attached
if (archivefile == null || archivefile.Length == 0)
{
    _notificationService.ErrorNotification("Please select a plugin/theme archive to upload.");
    return View();
}

Type guard

bool IsValidUpload(IFormFile f) => f != null && f.Length > 0;

Try / catch

// The UploadPluginsAndThemes try/catch shows exc.Message (resolved resource); add client-side required file validation.

Prevention

When it happens

Trigger: POST to UploadPluginsAndThemes with no file attached (multipart form missing the archivefile part) or with an empty zero-byte file.

Common situations: 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.

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/e88b65e05b7a4253. Report an issue: GitHub.