在magento代码中从前端上载自定义图像不起作用

在magento代码中从前端上载自定义图像不起作用,magento,Magento,我在magento的自定义模块中上载图像时遇到问题 为此我使用了核心php代码,但magento没有上传图像 我使用相同的代码在本地xampp中上传文件。 但该代码在我的服务器上不起作用 我也使用这个代码,但它也不工作 $path = Mage::getBaseDir().DS.'customer_documents'.DS; //desitnation directory $fname = $_FILES['docname']['name']; //file name $uploade

我在magento的自定义模块中上载图像时遇到问题

为此我使用了核心php代码,但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

我已经在我的代码中添加了这一行,它正在工作

<?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
?>

发生了什么事?您遇到了什么错误?图像未上载。。但是现在我的问题解决了。。错误是。。。我忘记了将magento file uploader.phpPost您的解决方案作为答案并接受它,因此问题显示为已完成/已回答。在哪里编写此代码?它的路径是什么,变量是什么,输入文件名是什么??答案不清楚,请编辑