how to store a canvas image to mysql and retrieve it using nodejsHow to Vertical align elements in a div?Make a div fill the height of the remaining screen spaceHow to make an image center (vertically & horizontally) inside a bigger divConvert HTML + CSS to PDF with PHP?How do I give text or an image a transparent background using CSS?How to move an element into another element?How to store Node.js deployment settings/configuration files?How can I update NodeJS and NPM to the next versions?How do I vertically center text with CSS?Is it possible to apply CSS to half of a character?
I was contacted by a private bank overseas to get my inheritance
Why should public servants be apolitical?
What does Fisher mean by this quote?
If there were no space agencies, could a person go to space?
Is there such thing as a "3-dimensional surface?"
Secure my password from unsafe servers
How do I say "Outdoor Pre-show"
Premier League simulation
How many years before enough atoms of your body are replaced to survive the sudden disappearance of the original body’s atoms?
Is Odin inconsistent about the powers of Mjolnir?
Short story about a teenager who has his brain replaced with a microchip (Psychological Horror)
ESTA declined to the US
French equivalent of "Make leaps and bounds"
WordCloud: do not eliminate duplicates
Our group keeps dying during the Lost Mine of Phandelver campaign. What are we doing wrong?
Can I enter a rental property without giving notice if I'm afraid a tenant may be hurt?
Looking for a new job because of relocation - is it okay to tell the real reason?
What was the first multiprocessor x86 motherboard?
Should I take out a personal loan to pay off credit card debt?
Why does putting a dot after the URL remove login information?
What are these silver stripes on Cosmic Girl for?
Why do proponents of guns oppose gun competency tests?
Is this cheap "air conditioner" able to cool a room?
sytemctl status log output
how to store a canvas image to mysql and retrieve it using nodejs
How to Vertical align elements in a div?Make a div fill the height of the remaining screen spaceHow to make an image center (vertically & horizontally) inside a bigger divConvert HTML + CSS to PDF with PHP?How do I give text or an image a transparent background using CSS?How to move an element into another element?How to store Node.js deployment settings/configuration files?How can I update NodeJS and NPM to the next versions?How do I vertically center text with CSS?Is it possible to apply CSS to half of a character?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a div and took a snapshot of that div using canvas and stored canvas image in a variable getcanvas, Now I want to store that canvas image to mysqldatabase using node
jquery html node.js
add a comment |
I have a div and took a snapshot of that div using canvas and stored canvas image in a variable getcanvas, Now I want to store that canvas image to mysqldatabase using node
jquery html node.js
1
Pure code-writing requests are off-topic on Stack Overflow — we expect questions here to relate to specific programming problems — but we will happily help you write it yourself! Tell us what you've tried, and where you are stuck. This will also help us answer your question better.
– Stefan Becker
Mar 27 at 6:11
add a comment |
I have a div and took a snapshot of that div using canvas and stored canvas image in a variable getcanvas, Now I want to store that canvas image to mysqldatabase using node
jquery html node.js
I have a div and took a snapshot of that div using canvas and stored canvas image in a variable getcanvas, Now I want to store that canvas image to mysqldatabase using node
jquery html node.js
jquery html node.js
asked Mar 27 at 5:55
Virat AchugatlaVirat Achugatla
31 bronze badge
31 bronze badge
1
Pure code-writing requests are off-topic on Stack Overflow — we expect questions here to relate to specific programming problems — but we will happily help you write it yourself! Tell us what you've tried, and where you are stuck. This will also help us answer your question better.
– Stefan Becker
Mar 27 at 6:11
add a comment |
1
Pure code-writing requests are off-topic on Stack Overflow — we expect questions here to relate to specific programming problems — but we will happily help you write it yourself! Tell us what you've tried, and where you are stuck. This will also help us answer your question better.
– Stefan Becker
Mar 27 at 6:11
1
1
Pure code-writing requests are off-topic on Stack Overflow — we expect questions here to relate to specific programming problems — but we will happily help you write it yourself! Tell us what you've tried, and where you are stuck. This will also help us answer your question better.
– Stefan Becker
Mar 27 at 6:11
Pure code-writing requests are off-topic on Stack Overflow — we expect questions here to relate to specific programming problems — but we will happily help you write it yourself! Tell us what you've tried, and where you are stuck. This will also help us answer your question better.
– Stefan Becker
Mar 27 at 6:11
add a comment |
1 Answer
1
active
oldest
votes
Two ways
- save image as dataUrl (i.e. a string).
/* send */
const dataUrl = canvas.toDataURL()
// TODO: post dataUrl to server and save it to mysql
/* get */
// get dataUrl from server
const img = document.createElement('img');
// attach dataUrl to img.src to show it
img.src = dataUrl
- save canvas image as a real image
/* send */
const dataUrl = canvas.toDataURL()
const [memeStr, dataStr] = (dataUrl || '').split(',')
const mime = memeStr
.split(',')[0]
.split(':')[1]
.split(';')[0]
const bstr = atob(dataStr)
const u8arr = new Uint8Array(bstr.length)
for (let i = 0; i < bstr.length; i++)
u8arr[i] = bstr.charCodeAt(i)
const imageFile = new Blob([u8arr], type: mime )
// TODO: you got the image file (by default is a png file)
// send it to the server and store its path in mysql
/* get */
// get imagePath from server
const img = document.createElement('img');
// attach imagePath to img.src to show it
img.src = imagePath
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370654%2fhow-to-store-a-canvas-image-to-mysql-and-retrieve-it-using-nodejs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Two ways
- save image as dataUrl (i.e. a string).
/* send */
const dataUrl = canvas.toDataURL()
// TODO: post dataUrl to server and save it to mysql
/* get */
// get dataUrl from server
const img = document.createElement('img');
// attach dataUrl to img.src to show it
img.src = dataUrl
- save canvas image as a real image
/* send */
const dataUrl = canvas.toDataURL()
const [memeStr, dataStr] = (dataUrl || '').split(',')
const mime = memeStr
.split(',')[0]
.split(':')[1]
.split(';')[0]
const bstr = atob(dataStr)
const u8arr = new Uint8Array(bstr.length)
for (let i = 0; i < bstr.length; i++)
u8arr[i] = bstr.charCodeAt(i)
const imageFile = new Blob([u8arr], type: mime )
// TODO: you got the image file (by default is a png file)
// send it to the server and store its path in mysql
/* get */
// get imagePath from server
const img = document.createElement('img');
// attach imagePath to img.src to show it
img.src = imagePath
add a comment |
Two ways
- save image as dataUrl (i.e. a string).
/* send */
const dataUrl = canvas.toDataURL()
// TODO: post dataUrl to server and save it to mysql
/* get */
// get dataUrl from server
const img = document.createElement('img');
// attach dataUrl to img.src to show it
img.src = dataUrl
- save canvas image as a real image
/* send */
const dataUrl = canvas.toDataURL()
const [memeStr, dataStr] = (dataUrl || '').split(',')
const mime = memeStr
.split(',')[0]
.split(':')[1]
.split(';')[0]
const bstr = atob(dataStr)
const u8arr = new Uint8Array(bstr.length)
for (let i = 0; i < bstr.length; i++)
u8arr[i] = bstr.charCodeAt(i)
const imageFile = new Blob([u8arr], type: mime )
// TODO: you got the image file (by default is a png file)
// send it to the server and store its path in mysql
/* get */
// get imagePath from server
const img = document.createElement('img');
// attach imagePath to img.src to show it
img.src = imagePath
add a comment |
Two ways
- save image as dataUrl (i.e. a string).
/* send */
const dataUrl = canvas.toDataURL()
// TODO: post dataUrl to server and save it to mysql
/* get */
// get dataUrl from server
const img = document.createElement('img');
// attach dataUrl to img.src to show it
img.src = dataUrl
- save canvas image as a real image
/* send */
const dataUrl = canvas.toDataURL()
const [memeStr, dataStr] = (dataUrl || '').split(',')
const mime = memeStr
.split(',')[0]
.split(':')[1]
.split(';')[0]
const bstr = atob(dataStr)
const u8arr = new Uint8Array(bstr.length)
for (let i = 0; i < bstr.length; i++)
u8arr[i] = bstr.charCodeAt(i)
const imageFile = new Blob([u8arr], type: mime )
// TODO: you got the image file (by default is a png file)
// send it to the server and store its path in mysql
/* get */
// get imagePath from server
const img = document.createElement('img');
// attach imagePath to img.src to show it
img.src = imagePath
Two ways
- save image as dataUrl (i.e. a string).
/* send */
const dataUrl = canvas.toDataURL()
// TODO: post dataUrl to server and save it to mysql
/* get */
// get dataUrl from server
const img = document.createElement('img');
// attach dataUrl to img.src to show it
img.src = dataUrl
- save canvas image as a real image
/* send */
const dataUrl = canvas.toDataURL()
const [memeStr, dataStr] = (dataUrl || '').split(',')
const mime = memeStr
.split(',')[0]
.split(':')[1]
.split(';')[0]
const bstr = atob(dataStr)
const u8arr = new Uint8Array(bstr.length)
for (let i = 0; i < bstr.length; i++)
u8arr[i] = bstr.charCodeAt(i)
const imageFile = new Blob([u8arr], type: mime )
// TODO: you got the image file (by default is a png file)
// send it to the server and store its path in mysql
/* get */
// get imagePath from server
const img = document.createElement('img');
// attach imagePath to img.src to show it
img.src = imagePath
answered Mar 27 at 6:18
troytroy
1727 bronze badges
1727 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370654%2fhow-to-store-a-canvas-image-to-mysql-and-retrieve-it-using-nodejs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
Pure code-writing requests are off-topic on Stack Overflow — we expect questions here to relate to specific programming problems — but we will happily help you write it yourself! Tell us what you've tried, and where you are stuck. This will also help us answer your question better.
– Stefan Becker
Mar 27 at 6:11