You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Magento 1.9.0.1更新后后台无法上传新产品图片

Alright, let's break down your problem and walk through actionable fixes step by step:

Quick Recap of Your Scenario

  • You fixed the initial cannot read property 'checked' of undefined error by modifying gallery.phtml
  • Post-fix: Images successfully upload to the tmp folder, Ajax returns 200 OK, no console errors—but images don't show up in the gallery or save to the database
  • Tried switching to Dull Uploader with no improvement

Potential Causes & Fixes

1. Validate Gallery Initialization Data

The core gallery initialization line you shared is critical—let's make sure its data is valid:

var <?php echo $_block->getJsObjectName(); ?> = new Product.Gallery('<?php echo $_block->getHtmlId() ?>', <?php echo $_block->getImageTypesJson() ?>);
  • Check getImageTypesJson() output: Temporarily add <?php var_dump($_block->getImageTypesJson()); ?> to gallery.phtml to see if it returns valid, non-empty JSON. Corrupted or missing image type data (Base/Small/Thumbnail) will break the gallery's ability to register uploaded images.
    • If it's malformed/empty, verify your product attribute set has the standard image attributes assigned and enabled.

2. Inspect Ajax Request Metadata

Even if the file hits tmp, the gallery might not be sending required data to link it to your product:

  • Open your browser's Network tab, trigger an upload, and check the upload request parameters:
    • Ensure form_key, product (product ID), and tmp_name are all present.
    • If form_key is missing, add it explicitly to the upload form data in gallery.phtml:
      formData.append('form_key', window.FORM_KEY);
      
    • A missing product ID means the system can't associate the temp image with your product—double-check that the product ID is being passed correctly from the page.

3. Verify Permissions Beyond Uploader.php

You checked Uploader.php, but let's cover other critical directories:

  • Ensure pub/media/catalog/product (and all subfolders) has write permissions for your web server user (usually www-data, apache, or nginx).
  • Temporarily set the tmp upload folder to 777 to rule out permission blocks (lock it back to 755 once confirmed).
  • Confirm the web server user owns these directories with:
    chown -R www-data:www-data pub/media/catalog/product
    

4. Check for Accidental JS Corruption in gallery.phtml

Since you modified this file, compare your version to a fresh Magento core gallery.phtml to spot missing/altered code:

  • Pay close attention to sections handling post-upload image registration—even a missing comma or misplaced function call can break the gallery's ability to render and save images.
  • Ensure the Product.Gallery constructor receives all required parameters (the second argument for image types is non-negotiable).

5. Debug Database EAV Entries

If temp files exist but no DB entries are created, check your product's media gallery data:

  • Run this SQL query (replace [PRODUCT_ID] with your product's ID):
    SELECT * FROM catalog_product_entity_media_gallery WHERE entity_id = [PRODUCT_ID];
    
    • If no rows return, the issue is in the code that inserts into this table—debug the saveMediaGallery method in your product model.
  • Also verify that image attributes (image, small_image, thumbnail) are set to "Visible on Product View Page" and "Used in Product Listing" in your attribute settings.

Final Quick Test

Try creating a brand new product and uploading an image to it. If that works, your original product likely has corrupted data. If it still fails, the problem lies in your global gallery/upload configuration.

内容的提问来源于stack exchange,提问作者Ravi Singh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:44:31