From 3d1663279af813dafd19f128569c7c8fa4b34dea Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Mon, 17 Dec 2012 15:45:40 +0100 Subject: [PATCH] [-] BO : fixed image upload (except with OVH firewall) #PSCFV-6152 #PSCFV-6157 #PSCFV-5862 #PSCFV-5756 #PSCFV-6074 #PSCFV-5459 --- classes/FileUploader.php | 11 +++++------ controllers/admin/AdminImportController.php | 18 +++++++++--------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/classes/FileUploader.php b/classes/FileUploader.php index 326eb9ef3..8958cec67 100755 --- a/classes/FileUploader.php +++ b/classes/FileUploader.php @@ -162,14 +162,13 @@ class QqUploadedFileXhr public function upload($path) { $input = fopen('php://input', 'r'); - $temp = tmpfile(); - $realSize = stream_copy_to_stream($input, $temp); - fclose($input); + $target = fopen($path, 'w'); + + $realSize = stream_copy_to_stream($input, $target); if ($realSize != $this->getSize()) return false; - $target = fopen($path, 'w'); - fseek($temp, 0, SEEK_SET); - stream_copy_to_stream($temp, $target); + + fclose($input); fclose($target); return true; diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index a6c0ddcf1..f3b3fb68d 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -638,20 +638,20 @@ class AdminImportControllerCore extends AdminController if (empty($field)) return array(); - if (is_null(Tools::getValue('multiple_value_separator')) || trim(Tools::getValue('multiple_value_separator')) == '') + $separator = Tools::getValue('multiple_value_separator'); + if (is_null($separator) || trim($separator) == '') $separator = ','; - else - $separator = Tools::getValue('multiple_value_separator'); - $temp = tmpfile(); - fwrite($temp, $field); - rewind($temp); - $tab = fgetcsv($temp, MAX_LINE_SIZE, $separator); - fclose($temp); + do $uniqid = uniqid(); while (file_exists(_PS_UPLOAD_DIR_.$uniqid)); + $tmp_file = file_put_contents(_PS_UPLOAD_DIR_.$uniqid, $field); + $fd = fopen($temp, 'r'); + $tab = fgetcsv($fd, MAX_LINE_SIZE, $separator); + fclose($fd); + unlink($tmp_file); + if (empty($tab) || (!is_array($tab))) return array(); return $tab; - } protected static function createMultiLangField($field)