2013-07-31 26 views
0

我使用system.xml配置通过后端上传文件。它完美的作品。如何在Magento中更改上传的文件名?

但我需要将上传图片的名称更改为当前store id。我怎么能够?现在它以原始名称上传。

system.xml

<?xml version="1.0"?> 
<config> 
    <tabs> 
    <restaurant translate="label" module="restaurant"> 
     <label>Upload Logo</label> 
     <sort_order>999999</sort_order> 
    </restaurant> 
    </tabs> 
    <sections> 
    <restaurant_options translate="label"> 
     <label>Upload Logo</label> 
     <tab>general</tab> 
     <frontend_type>text</frontend_type> 
     <sort_order>1000</sort_order> 
     <show_in_default>1</show_in_default> 
     <show_in_website>1</show_in_website> 
     <show_in_store>1</show_in_store> 
     <groups> 
      <SAMPLE translate="label"> 
       <label>Upload Your Store's Logo</label> 
       <frontend_type>text</frontend_type> 
       <sort_order>100</sort_order> 
       <show_in_default>1</show_in_default> 
       <show_in_website>1</show_in_website> 
       <show_in_store>1</show_in_store> 
       <fields> 
        <ENABLED translate="label comment"> 
         <label>Logo</label> 
         <comment>file types: jpeg, gif, png.</comment> 
         <frontend_type>image</frontend_type> 
         <backend_model>adminhtml/system_config_backend_image</backend_model> 
         <upload_dir config="system/filesystem/media" scope_info="1">theme</upload_dir> 
         <base_url type="media" scope_info="1">theme</base_url> 
         <sort_order>1</sort_order> 
         <show_in_default>1</show_in_default> 
         <show_in_website>1</show_in_website> 
         <show_in_store>1</show_in_store> 
        </ENABLED> 
      </fields> 
      </SAMPLE> 
     </groups> 
    </restaurant_options> 
    </sections> 
</config> 

如有任何知道解决办法。

回答

0

据我所知。 首先在数据库中插入记录,并使用

$ uniqID = mysql_insert_id();

然后

move_uploaded_file($ _ FILES [ 'userfile的'] [ 'tmp_name的值'],$ $ path_to_upload uniqID。);

请注意:不要忘记获取文件扩展名。

相关问题