magento后台使用POST表单时,要使用必要参数form_key才能正常通讯

<form action="<?php echo $this->getSaveUrl() ?>" method="POST" enctype="multipart/form-data">
<label for="up_file">批量处理表格:</label>
<input type="file" name="up_file" id="up_file" value="选择文件" />
<!--没有这个form_key会被重定向到首页-->
<input type="hidden" name="form_key" value="<?=Mage::getSingleton('core/session')->getFormKey() ?>">
<br/>
<br/>
<input type="submit" value="导入">
<br/>
<br/>

<hr/>
<br/>
<br/>

<span>本地共导入条<?=$this->getTotalNum()?>数据,成功<?=$this->getSuccNum()?>条,失败<?=$this->getErrorNum()?>条。</span>
<br/>
<br/>

<table class="uptemplate_result_table">
<tr>
<th></th>
<th>SKU</th>
<th>错误提示</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</form>



<form action="http://www.5s.cn/index.php/5staradmin2013/catalog_product/upTemplate/key/fbdb8679355c0dfa12387b303374af130c9bb20241454b129659f2134eb91292/" method="POST" enctype="multipart/form-data">
    <label for="up_file">批量处理表格:</label>
    <input type="file" name="up_file" id="up_file" value="选择文件">
    <input type="hidden" name="form_key" value="eswJsUit3B1OCmdp">
    <br>
    <br>
    <input type="submit" value="导入">
    <br>
    <br>

    <hr>
    <br>
    <br>

    <span>本地共导入条10数据,成功10条,失败10条。</span>
    <br>
    <br>

    <table class="uptemplate_result_table">
        <tbody><tr>
            <th>行</th>
            <th>SKU</th>
            <th>错误提示</th>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </tbody></table>
</form>




原文地址:https://www.cnblogs.com/caryfang/p/5511517.html