diff --git a/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl
index c867b6c6d..1b7f2fe2c 100644
--- a/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl
+++ b/admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl
@@ -67,20 +67,30 @@
{l s='Upload'}
diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php
index 2aefb235c..0f06fa577 100644
--- a/controllers/admin/AdminImportController.php
+++ b/controllers/admin/AdminImportController.php
@@ -513,7 +513,7 @@ class AdminImportControllerCore extends AdminController
$this->context->cookie->entity_selected = (int)Tools::getValue('entity');
- if ($csv_selected = Tools::getValue('csv'))
+ if (Tools::getValue('csv'))
$this->context->cookie->csv_selected = Tools::getValue('csv');
$this->tpl_view_vars = array(
@@ -2555,7 +2555,6 @@ class AdminImportControllerCore extends AdminController
{
if ($a == $b)
return 0;
-
return ($a < $b) ? 1 : -1;
}
@@ -2700,6 +2699,7 @@ class AdminImportControllerCore extends AdminController
if (Tools::isSubmit('submitFileUpload'))
{
+ $path = _PS_ADMIN_DIR_.'/import/'.date('Ymdhis').'-';
if (isset($_FILES['file']) && !empty($_FILES['file']['error']))
{
switch ($_FILES['file']['error'])
@@ -2726,12 +2726,15 @@ class AdminImportControllerCore extends AdminController
}
}
else if (!file_exists($_FILES['file']['tmp_name']) ||
- !@move_uploaded_file($_FILES['file']['tmp_name'], _PS_ADMIN_DIR_.'/import/'.date('Ymdhis').'-'.$_FILES['file']['name']))
+ !@move_uploaded_file($_FILES['file']['tmp_name'], $path.$_FILES['file']['name']))
$this->errors[] = $this->l('An error occurred while uploading / copying the file.');
else
+ {
+ @chmod($path.$_FILES['file']['name'], 0664);
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=18');
+ }
}
- else if (Tools::getValue('import'))
+ elseif (Tools::getValue('import'))
{
// Check if the CSV file exist
if (Tools::getValue('csv'))
@@ -2795,7 +2798,35 @@ class AdminImportControllerCore extends AdminController
else
$this->errors[] = $this->l('You must upload a file in order to proceed to the next step');
}
+ elseif($filename = Tools::getValue('csvfilename'))
+ {
+ $filename = base64_decode($filename);
+ $file = _PS_ADMIN_DIR_.'/import/'.basename($filename);
+ if (!empty($filename) && file_exists($file))
+ {
+ $bName = basename($filename);
+ $bName = explode('.', $bName);
+ $bName = strtolower($bName[count($bName) - 1]);
+ $mimeTypes = array('csv' => 'text/csv');
+ if (isset($mimeTypes[$bName]))
+ $mimeType = $mimeTypes[$bName];
+ else
+ $mimeType = 'application/octet-stream';
+
+ if (ob_get_level())
+ ob_end_clean();
+
+ header('Content-Transfer-Encoding: binary');
+ header('Content-Type: '.$mimeType);
+ header('Content-Length: '.filesize($file));
+ header('Content-Disposition: attachment; filename="'.$filename.'"');
+ $fp = fopen($file, 'rb');
+ while (!feof($fp))
+ echo fgets($fp, 16384);
+ }
+ exit;
+ }
parent::postProcess();
}