0

system.xml 構成を使用して、バックエンド経由でファイルをアップロードしています。それは完全に機能します。

しかし、アップロードされた画像の名前を現在の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>

解決策を知っている場合はお願いします。

4

1 に答える 1

0

私の知る限りでは。最初にレコードをデータベースに挿入し、挿入されたIDを使用して取得します

$uniqID = mysql_insert_id();

それから

move_uploaded_file($_FILES['userFile']['tmp_name'], $path_to_upload . $uniqID);

注意: ファイル拡張子を取得することを忘れないでください。

于 2013-07-31T06:54:13.873 に答える