2014-10-08 91 views
1

當我從後端管理面板上傳產品圖像時,對此問題的任何幫助都表示讚賞,但我收到此錯誤。PHP在Magento中上傳產品圖像時出現Foreach錯誤

Warrning: Invalid argument supplied for foreach() in /Applications/AMPPS/www/magento/app/code/core/Mage/Core/Model/File/Validator/NotProtectedExtension.php on line 91 

做了一些調試後,我明白,

被返回null,因此在foreach錯誤。

我最近沒有上傳任何圖片,所以我不知道是什麼特別的改變觸發了這個。

回答

0

檢查你有這樣的:

<protected_extensions> 
    <!-- PHP script file extension --> 
    <php>php</php> 
    <!-- File extension of configuration of an Apache Web server --> 
    <htaccess>htaccess</htaccess> 
    <!-- Java script file extension --> 
    <jsp>jsp</jsp> 
    <!-- Perl script file extension --> 
    <pl>pl</pl> 
    <!-- Python script file extension --> 
    <py>py</py> 
    <!-- Active Server Page script file extension --> 
    <asp>asp</asp> 
    <!-- UNIX command prompt file extension --> 
    <sh>sh</sh> 
    <!-- Common Gateway Interface script extension type --> 
    <cgi>cgi</cgi> 
    <!-- BOF HTML file extensions --> 
    <htm>htm</htm> 
    <html>html</html> 
    <phtml>phtml</phtml> 
    <shtml>shtml</shtml> 
    <!-- EOF HTML file extensions --> 
</protected_extensions> 
app\code\Core\Magento\Core\etc\config.xml(377-400線在Magento 1.7.0.1)

如果沒有,您編輯了一個核心文件,這不是一個好主意。如果它在那裏,檢查你的db,core_config_table,path ='general/file/protected_extensions'。應該沒有什麼。
最後,檢查其他模塊(社區和地方)的config.xml中是否有這個參數設置爲默認值,像塊:

<config> 
    .... 
    <default> 
     .... 
     <general> 
      <file> 
       <protected_extensions> 
        .... 
       </protected_extensions> 
      </file> 
     </general> 
    </default> 
     .... 
</config> 
+0

感謝OSdave快速回復所有的鍵,我試過的所有3你的建議,一切都如預期,但仍然相同 – Hiren 2014-10-08 12:17:15

3

在調試浪費了一天之後想通了這個問題錯誤

我可能已經搞砸與安裝腳本,並在core_config_data表插入下面一行

path => 'general', value => NULL 

這導致在配置樹「一般」爲指向NULL,並因此關鍵

'general/file/protected_extensions' 

從來沒有可降。由於數據庫值填充,並從XML文件中獲取配置值後加入以後,上述排抹殺開始與路徑一般

+0

我也有同樣的問題和解決方案,但我的價值是1。不知道它是如何被插入。你能把這個標記爲接受的答案嗎? – Luke 2016-09-30 13:23:37