2

Magento のカスタム モジュールで画像をアップロードする際に問題が発生しました。

私はこの目的のためにコアphp ccodingを使用しましたが、magentoは画像をアップロードしていません..

同じコードを使用して、ローカルの xampp にファイルをアップロードしました。しかし、そのコードは私のサーバーでは機能していません..

私もこのコードを使用していますが、機能していません....

$path = Mage::getBaseDir().DS.'customer_documents'.DS; //desitnation directory
  $fname = $_FILES['docname']['name']; //file name
  $uploader = new Varien_File_Uploader('docname'); //load class
  $uploader->setAllowedExtensions(array('doc','pdf','txt','docx')); //Allowed extension for file
  $uploader->setAllowCreateFolders(true); //for creating the directory if not exists
  $uploader->setAllowRenameFiles(false); //if true, uploaded file's name will be changed, if file with the same name already exists directory.
  $uploader->setFilesDispersion(false);
  $uploader->save($path,$fname); //save the file on the specified path
4

1 に答える 1

1

コードにこの行を追加しましたが、動作しています..

<?php require_once ("lib/Varien/File/Uploader.php");?>

この後、このコードを書いてください

<?php
$path = Mage::getBaseDir().DS.'customer_documents'.DS; //desitnation directory
  $fname = $_FILES['docname']['name']; //file name
  $uploader = new Varien_File_Uploader('docname'); //load class
  $uploader->setAllowedExtensions(array('doc','pdf','txt','docx')); //Allowed extension for file
  $uploader->setAllowCreateFolders(true); //for creating the directory if not exists
  $uploader->setAllowRenameFiles(false); //if true, uploaded file's name will be changed, if file with the same name already exists directory.
  $uploader->setFilesDispersion(false);
  $uploader->save($path,$fname); //save the file on the specified path
?>
于 2012-09-27T06:03:12.853 に答える