我在使用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
答案 0 :(得分: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
?>