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;








-1















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










share|improve this question



















  • 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















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










share|improve this question



















  • 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








-1








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










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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












  • 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












1 Answer
1






active

oldest

votes


















0














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





share|improve this answer
























    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%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









    0














    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





    share|improve this answer





























      0














      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





      share|improve this answer



























        0












        0








        0







        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





        share|improve this answer













        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






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 27 at 6:18









        troytroy

        1727 bronze badges




        1727 bronze badges



















            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.



















            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%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





















































            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

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해