Query the database image files

开发工具与关键技术:vs2015  MVC
作者:陈星宇
撰写时间:2019.5.26

When we save the picture types of data into the database, not the preservation picture file, but a file of binary data stream, where I teach you how to read a binary array of database file stream.
First we have to put the body in an IMG tag, for a space to read data generated by the picture,
we let the IMG SRC tag attribute is empty, and so will we use the method to set the SRC our pictures came out, we have to the IMG tag for an ID, used to select the tag.
Here Insert Picture Description
Then we get through the ID to the IMG tag, and then use the method attr, give this IMG tag to set properties, we are here to give this label to set the SRC attribute, and the link is how we want to submit, we need to pass a parameter as a condition check out we want to set out the picture data.
Here Insert Picture Description
Then we get to the ID, and then you can check out the data in the database from IMG.
Here Insert Picture Description
We can see check out the data byte, but also an array.
Since the data query out, and then we will have to judge whether the data, and if we have data back into the data directly, without data, we can read the local data.
Here Insert Picture Description
Here is the return to return by file type, data format is image / jpg format, we will return the data to the page, and then set to SRC IMG tag attr, then a picture on the query out.

Guess you like

Origin blog.csdn.net/tianxiu11/article/details/90612684