Froala Error in Image Upload. Not showing the image in the froala editor












0















Im working with Angular6 and when I upload an Image with Froala I got this error in the Froala Editor:




Something went wrong. Please try again.




errorImage



My server-side code its ok, the image gets uploaded, and I get the JSON response with the right url.



My code:



    //component.ts:

public options: Object = {
charCounterCount: true,


// Set the image upload URL.
imageUploadURL: 'http://localhost:3000/upload_image',

// Additional upload params.
imageUploadParams: {id: 'my_editor'},

// Set request type.
imageUploadMethod: 'POST',


};




    //component.html

<div class="row">
<div [froalaEditor]="options" [(froalaModel)]="contenidoTema"></div>
</div>




//server-side code
//app.js

var FroalaEditor = require('wysiwyg-editor-node-sdk/lib/froalaEditor.js');
app.use(express.static(__dirname + '/'));
app.use('/bower_components', express.static(path.join(__dirname, '../bower_components')));
app.use(bodyParser.urlencoded({ extended: false }));

// Path to upload image.
app.post('/upload_image', function (req, res) {

// Store image.
FroalaEditor.Image.upload(req, '/uploads/', function(err, data) {
res.setHeader('Content-Type', 'application/json');
res.setHeader('Allow', 'GET, POST, OPTIONS');
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', '*');
res.setHeader('Content-Length', '0');
// Return data.
if (err) {
return res.send(JSON.stringify(err));
}
console.log("http://localhost:3000"+data.link);
res.send("http://localhost:3000"+data.link);
});
});









share|improve this question























  • I am not sure if you will get a valid json response here res.send("http://localhost:3000"+data.link);

    – Joel Joseph
    Nov 21 '18 at 20:08








  • 1





    you will have to send the res.send({ link : "http://localhost:3000"+data.link });

    – Joel Joseph
    Nov 21 '18 at 20:09













  • OMG, so simple, that solved my issue. Thanks a lot ! :)

    – tw3R
    Nov 21 '18 at 20:11
















0















Im working with Angular6 and when I upload an Image with Froala I got this error in the Froala Editor:




Something went wrong. Please try again.




errorImage



My server-side code its ok, the image gets uploaded, and I get the JSON response with the right url.



My code:



    //component.ts:

public options: Object = {
charCounterCount: true,


// Set the image upload URL.
imageUploadURL: 'http://localhost:3000/upload_image',

// Additional upload params.
imageUploadParams: {id: 'my_editor'},

// Set request type.
imageUploadMethod: 'POST',


};




    //component.html

<div class="row">
<div [froalaEditor]="options" [(froalaModel)]="contenidoTema"></div>
</div>




//server-side code
//app.js

var FroalaEditor = require('wysiwyg-editor-node-sdk/lib/froalaEditor.js');
app.use(express.static(__dirname + '/'));
app.use('/bower_components', express.static(path.join(__dirname, '../bower_components')));
app.use(bodyParser.urlencoded({ extended: false }));

// Path to upload image.
app.post('/upload_image', function (req, res) {

// Store image.
FroalaEditor.Image.upload(req, '/uploads/', function(err, data) {
res.setHeader('Content-Type', 'application/json');
res.setHeader('Allow', 'GET, POST, OPTIONS');
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', '*');
res.setHeader('Content-Length', '0');
// Return data.
if (err) {
return res.send(JSON.stringify(err));
}
console.log("http://localhost:3000"+data.link);
res.send("http://localhost:3000"+data.link);
});
});









share|improve this question























  • I am not sure if you will get a valid json response here res.send("http://localhost:3000"+data.link);

    – Joel Joseph
    Nov 21 '18 at 20:08








  • 1





    you will have to send the res.send({ link : "http://localhost:3000"+data.link });

    – Joel Joseph
    Nov 21 '18 at 20:09













  • OMG, so simple, that solved my issue. Thanks a lot ! :)

    – tw3R
    Nov 21 '18 at 20:11














0












0








0


0






Im working with Angular6 and when I upload an Image with Froala I got this error in the Froala Editor:




Something went wrong. Please try again.




errorImage



My server-side code its ok, the image gets uploaded, and I get the JSON response with the right url.



My code:



    //component.ts:

public options: Object = {
charCounterCount: true,


// Set the image upload URL.
imageUploadURL: 'http://localhost:3000/upload_image',

// Additional upload params.
imageUploadParams: {id: 'my_editor'},

// Set request type.
imageUploadMethod: 'POST',


};




    //component.html

<div class="row">
<div [froalaEditor]="options" [(froalaModel)]="contenidoTema"></div>
</div>




//server-side code
//app.js

var FroalaEditor = require('wysiwyg-editor-node-sdk/lib/froalaEditor.js');
app.use(express.static(__dirname + '/'));
app.use('/bower_components', express.static(path.join(__dirname, '../bower_components')));
app.use(bodyParser.urlencoded({ extended: false }));

// Path to upload image.
app.post('/upload_image', function (req, res) {

// Store image.
FroalaEditor.Image.upload(req, '/uploads/', function(err, data) {
res.setHeader('Content-Type', 'application/json');
res.setHeader('Allow', 'GET, POST, OPTIONS');
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', '*');
res.setHeader('Content-Length', '0');
// Return data.
if (err) {
return res.send(JSON.stringify(err));
}
console.log("http://localhost:3000"+data.link);
res.send("http://localhost:3000"+data.link);
});
});









share|improve this question














Im working with Angular6 and when I upload an Image with Froala I got this error in the Froala Editor:




Something went wrong. Please try again.




errorImage



My server-side code its ok, the image gets uploaded, and I get the JSON response with the right url.



My code:



    //component.ts:

public options: Object = {
charCounterCount: true,


// Set the image upload URL.
imageUploadURL: 'http://localhost:3000/upload_image',

// Additional upload params.
imageUploadParams: {id: 'my_editor'},

// Set request type.
imageUploadMethod: 'POST',


};




    //component.html

<div class="row">
<div [froalaEditor]="options" [(froalaModel)]="contenidoTema"></div>
</div>




//server-side code
//app.js

var FroalaEditor = require('wysiwyg-editor-node-sdk/lib/froalaEditor.js');
app.use(express.static(__dirname + '/'));
app.use('/bower_components', express.static(path.join(__dirname, '../bower_components')));
app.use(bodyParser.urlencoded({ extended: false }));

// Path to upload image.
app.post('/upload_image', function (req, res) {

// Store image.
FroalaEditor.Image.upload(req, '/uploads/', function(err, data) {
res.setHeader('Content-Type', 'application/json');
res.setHeader('Allow', 'GET, POST, OPTIONS');
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', '*');
res.setHeader('Content-Length', '0');
// Return data.
if (err) {
return res.send(JSON.stringify(err));
}
console.log("http://localhost:3000"+data.link);
res.send("http://localhost:3000"+data.link);
});
});






node.js angular froala






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 19:42









tw3Rtw3R

486




486













  • I am not sure if you will get a valid json response here res.send("http://localhost:3000"+data.link);

    – Joel Joseph
    Nov 21 '18 at 20:08








  • 1





    you will have to send the res.send({ link : "http://localhost:3000"+data.link });

    – Joel Joseph
    Nov 21 '18 at 20:09













  • OMG, so simple, that solved my issue. Thanks a lot ! :)

    – tw3R
    Nov 21 '18 at 20:11



















  • I am not sure if you will get a valid json response here res.send("http://localhost:3000"+data.link);

    – Joel Joseph
    Nov 21 '18 at 20:08








  • 1





    you will have to send the res.send({ link : "http://localhost:3000"+data.link });

    – Joel Joseph
    Nov 21 '18 at 20:09













  • OMG, so simple, that solved my issue. Thanks a lot ! :)

    – tw3R
    Nov 21 '18 at 20:11

















I am not sure if you will get a valid json response here res.send("http://localhost:3000"+data.link);

– Joel Joseph
Nov 21 '18 at 20:08







I am not sure if you will get a valid json response here res.send("http://localhost:3000"+data.link);

– Joel Joseph
Nov 21 '18 at 20:08






1




1





you will have to send the res.send({ link : "http://localhost:3000"+data.link });

– Joel Joseph
Nov 21 '18 at 20:09







you will have to send the res.send({ link : "http://localhost:3000"+data.link });

– Joel Joseph
Nov 21 '18 at 20:09















OMG, so simple, that solved my issue. Thanks a lot ! :)

– tw3R
Nov 21 '18 at 20:11





OMG, so simple, that solved my issue. Thanks a lot ! :)

– tw3R
Nov 21 '18 at 20:11












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419457%2ffroala-error-in-image-upload-not-showing-the-image-in-the-froala-editor%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419457%2ffroala-error-in-image-upload-not-showing-the-image-in-the-froala-editor%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)