blob

php上传图片到mysql并显示

╄→尐↘猪︶ㄣ 提交于 2019-12-04 11:08:22
mysql可以直接保存二进制的数据,数据类型是blob。 通常在数据库中所使用的文本或整数类型的字段和需要用来保存图片的字段的不同之 处就在于两者所需要保存的数据量不同。MySQL数据库使用专门的字段来保存大容量的数据,数据 类型为BLOB。 MySQL数据库为BLOB做出的定义如下:BLOB数据类型是一种大型的二进制对象,可以保存可 变数量的数据。BLOB具有四种类型,分别是TINYBLOB,BLOB, MEDIUMBLOB 和LONGBLOB,区别在于各自所能够保存的最大数据长度不同 。 建立数据库 CREATE TABLE ccs_image ( id int(4) unsigned NOT NULL auto_increment, description varchar(250) default NULL, bin_data longblob, filename varchar(50) default NULL, filesize varchar(50) default NULL, filetype varchar(50) default NULL, PRIMARY KEY (id) ) 接着是上传文件的页面,upload.php,code如下: <HTML> <HEAD><TITLE>Store binary data into SQL Database</TITLE><

web下载附件及修改名称

杀马特。学长 韩版系。学妹 提交于 2019-12-04 11:07:55
1 /** 2 * @param: url 附件地址 3 * @param: filename 下载后的文件名 4 */ 5 function download(url, filename) { 6 getBlob(url, function (blob) { 7 saveAs(blob, filename); 8 }); 9 10 } 11 12 function getBlob(url, cb) { 13 14 var xhr = new XMLHttpRequest(); 15 16 xhr.open('GET', url, true); 17 18 xhr.responseType = 'blob'; 19 20 xhr.onload = function () { 21 22 if (xhr.status === 200) { 23 24 cb(xhr.response); 25 26 } 27 28 }; 29 30 xhr.send(); 31 32 } 33 34 function saveAs(blob, filename) { 35 36 if (window.navigator.msSaveOrOpenBlob) { 37 38 navigator.msSaveBlob(blob, filename); 39 40 } else { 41 42 var

deserialize java object from a blob

a 夏天 提交于 2019-12-04 10:18:09
first of all, i apologize, i'm about to ask a set of dumb questions. i don't know java AT ALL and i don't know if we are allowed to ask questions like these. if not - delete my topic. there's a table in oracle that stores a blob. it's binary and i'm able to decode it, the output looks like this ¬í sr /com.epam.insure.credentialing.forms.StorageBeanÀÓ ¯w/§ L variablest Ljava/util/Map;xpsr java.util.HashMapÚÁÃ`Ñ F loadFactorI thresholdxp?@ w t $_hasCompletedt t $_wf_progresssr java.lang.Integerâ ¤÷‡8 I valuexr java.lang.Number†¬•”à‹ xp t $_wf_statussq ~ t $_form_instance_idsr java.lang.Long;‹äÌ

Unable to retain line breaks when writing text file as blob

巧了我就是萌 提交于 2019-12-04 10:17:00
问题 I have a text area that contains text that I want to output to a text file for users to download. I'm using this function to grab it when users click the save button function saveTextAsFile() { var textToWrite = document.getElementById("inputText").value; var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'}); alert(textFileAsBlob); var fileNameToSaveAs = document.getElementById("inputFileNameToSaveAs").value; var downloadLink = document.createElement("a"); downloadLink.download =

mysql的char,varchar,text,blob的几点个人理解

僤鯓⒐⒋嵵緔 提交于 2019-12-04 10:02:16
mysql的char,varchar,text,blob是几个有联系但是有有很大区别的字段类型,这算是mysql的基础吧,可是基础没有学好,恶补一下。 先简单的总结一下: char: 定长 ,最大255个字符 varchar: 变长 ,最大65535个字符(既是单列的限制,又是整行的限制) text:变长,有字符集的大对象,并根据字符集进行排序和校验,大小写不敏感 blob:变长,无字符集的二进制大对象,大小写敏感 以下只是我个人的理解,才疏学浅,望各路高人指点。 我使用的引擎是myisam,所以以下的探讨是集中在myisam上的。 首先解释char,char是项目中常用的字段类型之一,它代表的含义是采用固定长度存储数据,换句话说,数据初始化的是就为该类型的字段分配固定长度的存储空间,即使没有达到存储空间的长度,实际占用的存储空间也是定义时的长度。举个例子来说,比如某字段 a char(50),指定的长度是50个字符的存储空间,那么当你存入一个字符:“abc”的时候,实际上字符长度是3个字符,但是占用的硬盘空间还是50个字符。很显然,char的缺点就出来了: 浪费存储空间 !但是同时char的优点也显示出来了: 固定长度,(索引)效率极高,不存在碎片 。 这里我们再探讨一下char的存储方式,虽然char会浪费极大的存储空间,但是你想过对于字符串的前后空格char是如何处理的吗?

How to get the name of a file downloaded with Angular $http?

﹥>﹥吖頭↗ 提交于 2019-12-04 08:53:24
问题 I've written code that uses Angular $http to download a file. The name of the file is not specified in the URL. The URL contains a unique identifier for the file, which is fetched from outside the application. When $http.get(myUrl) is called, everything works fine; the file is retrieved and I can access it in my callback handler, but I can't see how to get the name of the file. Capturing the raw response with Fiddler, I see this: HTTP/1.1 200 OK Cache-Control: private Content-Length: 54

How to post and retrieve blob with Django

杀马特。学长 韩版系。学妹 提交于 2019-12-04 08:24:41
I have a blob . It's an image that I resized using a <canvas> . I've verified that the data is correct by converting it to a url to test it as per the MDN guide . So far so good. Now, I'd like to post it to my Django server (along with some other inputs). So I do this: var fd = new FormData(form); canvas.toBlob( function(blob) { fd.set("image0", blob, "image0.jpg"); }, "image/jpeg", 0.7); var xhr = new XMLHttpRequest(); xhr.open('POST', '/ajax-upload/', true); xhr.setRequestHeader("X-CSRFToken", csrftoken); xhr.send(fd); I inspect the POST message with the network inspector console. My blob is

Html5's File API - BLOB usages?

最后都变了- 提交于 2019-12-04 07:29:13
问题 I have a file input : (jsbin) <input type="file" accept="image/*" id="input" multiple onchange='handleFiles(this)' /> Which , when file selected, shows small images of the selected image : I can do it in two ways : using FileReader : function handleFiles(t) //t=this { var fileList = t.files; for (var i = 0; i < fileList.length; i++) { var file = fileList[i]; var img = document.createElement("img"); img.style... = ... document.getElementById('body').appendChild(img); var reader = new

Play Framework Image BLOB File for Test Object Yaml

牧云@^-^@ 提交于 2019-12-04 07:16:37
How do you set up a Test Blob Image using the yaml structure? Also, what is the database structure for a BLOB file? (MySQL) I have experienced the same kind of problem a while ago on a project. However as I could not find a way to solve this with the fixtures (as the database stores the blob object as a string as Pere explained above), I created a workaround to at least solve this problem in a test-case-scenario. I created the following file /app/job/Bootstrap.java: import play.test.*; import play.jobs.*; import play.db.DB; import models.*; import java.util.List; @OnApplicationStart public

Binary data not stored properly in MySQL

回眸只為那壹抹淺笑 提交于 2019-12-04 07:09:46
问题 I want to store a base64_encoded string as binary data. So use base64_decode() on the string before inserting in a LONGBLOB field of MySQL. So far so good, however when I retrieve the data from MySQL, I can't generate the correct base64_encoded string which I have started with... How is this possible? Thanks in advance EDIT The stored data is an encrypted string with AES-256CBC OPENSSL encryption routine. CODE For my code I use OpenSSL to encrypt a string $string = "Test"; $IV =