Skip to content
Snippets Groups Projects
Commit 5618700d authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #59187 fix corrupted updated file

parent 0470d8f7
Branches
Tags
2 merge requests!2365Dev#59187 explo redmine pouvoir uploader des fichiers dans les tickets back office,!2357Dev#59187 explo redmine pouvoir uploader des fichiers dans les tickets back office
Pipeline #2589 failed with stage
in 20 minutes and 10 seconds
......@@ -185,7 +185,15 @@ class Admin_RedmineController extends ZendAfi_Controller_Action {
if (null !== $message = $service->validate())
return $this->_jsonError($this->_('Le service Redmine est invalide.'));
if (!$response = $service->uploadFile($this->_getParam('data')))
if(!$data = $this->_getParam('data'))
return $this->_jsonError($this->_('La pièce jointe est invalide.'));
$data = substr($data, strpos($data, ",") + 1);
if(!$data = base64_decode($data))
return $this->_jsonError($this->_('La pièce jointe est invalide.'));
if (!$response = $service->uploadFile($data))
return $this->_jsonError($this->_('L\'ajout de pièce jointe a échoué.'));
$decoded_response = json_decode($response, true);
......
......@@ -23,16 +23,17 @@
var reader = new FileReader();
reader.onloadend = function(e) {
var data_url = reader.result;
reader.onload = function(e) {
var file_content = e.target.result;
if(is_image) {
var image = new Image();
image.src = data_url;
image_preview.attr('src', data_url);
image.src = file_content;
image_preview.attr('src', file_content);
image_preview.show();
}
$.post(url,
{data: data_url},
{data: file_content,
processData: false},
function(data) {
if('message' in data)
return input_file.closest('form').find('#attachment_error').show().text(data.message);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment