-
I can't seem to figure out how to insert the image for whole day :D Here is my .php file where I handle the post request $target_dir = "uploaded/";
$target_file = $target_dir . basename($_FILES[$fileFieldName]["name"]);
if (move_uploaded_file($_FILES[$fileFieldName]["tmp_name"], $target_file)) {
$data = array(
'success' => true,
'file' => $target_file,
);
} else {
$data = array(
'success' => false,
);
}
echo json_encode($data); I tried using 'file' and 'url' in the $data array. Same outcome. .js file where I edit the trumbowyg $('#edit')
.trumbowyg({
btnsDef: {
// Create a new dropdown
image: {
dropdown: ['insertImage', 'upload'],
ico: 'insertImage'
}
},
// Redefine the button pane
btns: [
['viewHTML'],
['fontfamily'],
['fontsize'],
['formatting'],
['strong', 'em', 'del'],
['superscript', 'subscript'],
['indent', 'outdent'],
['lineheight'],
['link'],
['image'],
['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
['unorderedList', 'orderedList'],
['horizontalRule'],
['removeformat'],
['fullscreen'],
['foreColor', 'backColor'],
],
plugins: {
// Add imagur parameters to upload plugin for demo purposes
upload: {
serverPath: 'upload.php',
fileFieldName: 'image',
}
}
}); upload.php handles post request I added some console.logs to the trumbowyg.upload.js and its always going to the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey! I think your Content-Type is not set to |
Beta Was this translation helpful? Give feedback.
Hey!
I think your Content-Type is not set to
application/json
in the response :/