Display server-generated picture streams using jquery control

Source: Internet
Author: User

Preview:

First is the first pair is the initial page, the second is click Submit after the server generated two-dimensional code, not save the picture directly to the picture into a string back to the page.

Brief introduction:

First of all, this generation of QR code, and do not need to save the situation can be used in the front-end script to achieve, then I do this in the project.

Then JS seems to be unable to accept the service side of the file stream operation, for security reasons. If this way is possible, please tell me, thank you.

Since it is not possible to get the file stream, then get the string, tag has a special use, in SRC so data:image/png;base64, Ivborw0kggoaaaansuheugaaaaeaaaakcayaaabid .......... The following long string is the picture of the strings, and then the code, writing is easy.

Code:
Service side:
        Public ActionResult Getfileascii (string content)        {             System.IO.MemoryStream ms=new System.IO.MemoryStream ();            This step is to get the QR code            qrcodehelper.getqrcode (content, MS);            Return Content (Convert.tobase64string (Ms. GetBuffer ()));        }
Client:
            $.get (' url/* server address */', {content: ' http://blog.sina.com.cn/s/blog_50042fab0100mcuy.html/* to generate the contents of the QR code */'}, function ( Data) {                $ (' #testimg '). attr (' src ', ' data:image/png;base64, ' + data);            
Summarize:

The code is simple, not only the QR code, but does not need to save the picture can do so, like ' data:image/png;base64, can also be generated on the server.

Display server-generated picture streams using jquery control

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.