wysłał kilka plików dla każdego klienta w Magento ....Jak pobierać pliki Magento
potem wymienione szczegóły klientom przesłanym nazwy pliku ..
muszę pobrać plik przy użyciu kodu magento
jest to kod:
public function downloadAction() {
$entityid = $this->getRequest()->getParam('entity_id');
$customer_data = Mage::getModel('customer/customer')->load($entityid);
$filename = '';
if($customer_data){
$filename = $customer_data->getFileuploadname();
}
$filepath = '../uploads/'.$filename;
if (! is_file ($filepath) || ! is_readable ($filepath)) {
throw new Exception ();
}
$this->getResponse()
->setHttpResponseCode (200)
->setHeader ('Pragma', 'public', true)
->setHeader ('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
->setHeader ('Content-type', 'application/force-download')
->setHeader ('Content-Length', filesize($filepath))
->setHeader ('Content-Disposition', 'inline' . '; filename=' . basename($filepath));
$this->getResponse()->clearBody();
$this->getResponse()->sendHeaders();
readfile ($filepath);
//exit(0);
}
Ale didsplays błędów coś takiego:
Trace:
#0 D:\wamp\www\mysite\app\code\core\Mage\Core\Controller\Varien\Action.php(419): Managecustomers_Users_IndexController->downloadAction()
#1 D:\wamp\www\mysite\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('download')
#2 D:\wamp\www\mysite\app\code\core\Mage\Core\Controller\Varien\Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#3 D:\wamp\www\mysite\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#4 D:\wamp\www\mysite\app\Mage.php(683): Mage_Core_Model_App->run(Array)
#5 D:\wamp\www\mysite\index.php(87): Mage::run('', 'store')
#6 {main}
Folder uploads
znajduje się w folderze głównym Magento ...
Jak mogę pobrać plik ....
$filename
się nazwa pliku przesłanego przez pochodzi z bazy danych ...
Edycja:
Po usunięciu kod:
if (! is_file ($filepath) || ! is_readable ($filepath)) {
throw new Exception ();
}
Potem zmienił filepath jako:
$filepath = 'http://localhost/mysite/uploads/'.$filename;
Następnie pobraniem zrobione idealnie ....
ok mam go teraz .... – Kichu