M Masoud44 Member May 25, 2024 #1 Hi ... I have a database in mysql with 2 fields (id as int, image as blob) I used PostString to insert them, it is worked when using string type for data but the image in the string is big. so i decided to convert the image to bytes instead of string, because byte size is much smaller than string but i don't know how to Call php with string and bytes for insert into database
Hi ... I have a database in mysql with 2 fields (id as int, image as blob) I used PostString to insert them, it is worked when using string type for data but the image in the string is big. so i decided to convert the image to bytes instead of string, because byte size is much smaller than string but i don't know how to Call php with string and bytes for insert into database
M Masoud44 Member May 26, 2024 #3 Erel said: Switch to jRDC2. Click to expand... Hi Erel Thank you for your suggestion. But considering that the program is being released and I don't want to take risks and I don't have much time. Maybe it's better i'm to try another way and do Switch to jRDC2 at a suitable time. Maybe right now it's better with the combination putbyte and poststring I'll test it. of course, I know the upload speed will be slow. Upvote 0
Erel said: Switch to jRDC2. Click to expand... Hi Erel Thank you for your suggestion. But considering that the program is being released and I don't want to take risks and I don't have much time. Maybe it's better i'm to try another way and do Switch to jRDC2 at a suitable time. Maybe right now it's better with the combination putbyte and poststring I'll test it. of course, I know the upload speed will be slow.
Erel B4X founder Staff member Licensed User Longtime User May 26, 2024 #4 A simple solution is to use base64 encoding to encode bytes as string. This will allow you to use json (which I guess you are using). Upvote 0
A simple solution is to use base64 encoding to encode bytes as string. This will allow you to use json (which I guess you are using).
M Masoud44 Member May 26, 2024 #5 No, I didn't use Json I'm currently using the same base64 but the file size increases with base64. [CODE lang="b4x" title="length of file"] Dim out As OutputStream out.InitializeToBytesArray(0) Image.WriteToStream(out, 100, "JPEG") out.Close Log("length -------------------------------------") Log(out.ToBytesArray.Length) ------> 821,114 Dim su As StringUtils Log(su.EncodeBase64(out.ToBytesArray).Length) ------> 1,756,124 Return out.ToBytesArray[/CODE] Upvote 0
No, I didn't use Json I'm currently using the same base64 but the file size increases with base64. [CODE lang="b4x" title="length of file"] Dim out As OutputStream out.InitializeToBytesArray(0) Image.WriteToStream(out, 100, "JPEG") out.Close Log("length -------------------------------------") Log(out.ToBytesArray.Length) ------> 821,114 Dim su As StringUtils Log(su.EncodeBase64(out.ToBytesArray).Length) ------> 1,756,124 Return out.ToBytesArray[/CODE]
Andrew (Digitwell) Well-Known Member Licensed User Longtime User May 27, 2024 #6 Unfortunately, if you are using Multipart post to upload the file then the data will be encoded using BASE64. I have uploaded very large image files using this method to a php server. It is sometimes slow, but is works. You do need to remember to update your php.ini withe the upload file size limits. INI: ; Maximum allowed size for uploaded files. upload_max_filesize = 10M ; Must be greater than or equal to upload_max_filesize post_max_size = 12M ; Maximum amount of memory a script may consume (32MB) memory_limit = 128M ; Maximum number of files that can be uploaded via a single request max_file_uploads = 20 Upvote 0
Unfortunately, if you are using Multipart post to upload the file then the data will be encoded using BASE64. I have uploaded very large image files using this method to a php server. It is sometimes slow, but is works. You do need to remember to update your php.ini withe the upload file size limits. INI: ; Maximum allowed size for uploaded files. upload_max_filesize = 10M ; Must be greater than or equal to upload_max_filesize post_max_size = 12M ; Maximum amount of memory a script may consume (32MB) memory_limit = 128M ; Maximum number of files that can be uploaded via a single request max_file_uploads = 20
M Masoud44 Member May 27, 2024 #7 Andrew (Digitwell) said: I have uploaded very large image files using this method to a php server. It is sometimes slow, but is works. You do need to remember to update your php.ini withe the upload file size limits. Click to expand... Hi Andrew This is not my problem at the moment. I want to save the byte in the server database. Upvote 0
Andrew (Digitwell) said: I have uploaded very large image files using this method to a php server. It is sometimes slow, but is works. You do need to remember to update your php.ini withe the upload file size limits. Click to expand... Hi Andrew This is not my problem at the moment. I want to save the byte in the server database.
Andrew (Digitwell) Well-Known Member Licensed User Longtime User May 28, 2024 #8 Ah, I see. Why is that a problem? How to insert BLOB and CLOB files in MySQL? I want to store images and .docx/.doc, .pptx/.ppt, .pdf files using the front end of my software. I don't understand how to implement this and how to insert the BLOB and CLOB files into the table. ... stackoverflow.com Upvote 0
Ah, I see. Why is that a problem? How to insert BLOB and CLOB files in MySQL? I want to store images and .docx/.doc, .pptx/.ppt, .pdf files using the front end of my software. I don't understand how to implement this and how to insert the BLOB and CLOB files into the table. ... stackoverflow.com
M Masoud44 Member May 28, 2024 #9 Andrew (Digitwell) said: Ah, I see. Why is that a problem? How to insert BLOB and CLOB files in MySQL? I want to store images and .docx/.doc, .pptx/.ppt, .pdf files using the front end of my software. I don't understand how to implement this and how to insert the BLOB and CLOB files into the table. ... stackoverflow.com Click to expand... this is said about INSERT INTO table1 VALUES(v1,v2,...) with two way of use: 1-LOAD_FILE('path and file name') LOAD_FILE() is a string function(not byte) and this is use for save file name and path of it. 2- Insert file as hex string, e.g. - INSERT INTO table1 VALUES (1, x'89504E470D0A1A0A0000000D494........426082'); and this good for save hex string (not byte) Upvote 0
Andrew (Digitwell) said: Ah, I see. Why is that a problem? How to insert BLOB and CLOB files in MySQL? I want to store images and .docx/.doc, .pptx/.ppt, .pdf files using the front end of my software. I don't understand how to implement this and how to insert the BLOB and CLOB files into the table. ... stackoverflow.com Click to expand... this is said about INSERT INTO table1 VALUES(v1,v2,...) with two way of use: 1-LOAD_FILE('path and file name') LOAD_FILE() is a string function(not byte) and this is use for save file name and path of it. 2- Insert file as hex string, e.g. - INSERT INTO table1 VALUES (1, x'89504E470D0A1A0A0000000D494........426082'); and this good for save hex string (not byte)