R RBeaubien Member Licensed User Longtime User Dec 22, 2011 #1 I need to upload images to a web site, along with additional information such as Title, etc... I'm using the HttpUtils, and the application is crashing.. I am reading the file in, convert it to Base64, and doing a PostString. Here is the code I am using to read the image in, and convert it to Base64. Code: Copy inStream = File.OpenInput(photoPath, cur.GetString("PhotoFilename")) Dim buff(inStream.BytesAvailable) As Byte inStream.ReadBytes(buff, 0, inStream.BytesAvailable) tempVal = su.EncodeBase64(buff) however, as soon as that is complete, and it tries to execute the next line of code, the application gets an error "The application <name> (Process <name>) has stopped unexpectedly. Please try again". Two questions... 1) Is that code correct for converting the file to Base64 string? 2) Is there a better way to upload a file with additional data? Thanks!
I need to upload images to a web site, along with additional information such as Title, etc... I'm using the HttpUtils, and the application is crashing.. I am reading the file in, convert it to Base64, and doing a PostString. Here is the code I am using to read the image in, and convert it to Base64. Code: Copy inStream = File.OpenInput(photoPath, cur.GetString("PhotoFilename")) Dim buff(inStream.BytesAvailable) As Byte inStream.ReadBytes(buff, 0, inStream.BytesAvailable) tempVal = su.EncodeBase64(buff) however, as soon as that is complete, and it tries to execute the next line of code, the application gets an error "The application <name> (Process <name>) has stopped unexpectedly. Please try again". Two questions... 1) Is that code correct for converting the file to Base64 string? 2) Is there a better way to upload a file with additional data? Thanks!
R RBeaubien Member Licensed User Longtime User Dec 23, 2011 #2 Ok, figured out what I was doing wrong with the input stream. Should have gotten the size of the file and not used the BytesAvailable as the two won't necessarily match. Upvote 0
Ok, figured out what I was doing wrong with the input stream. Should have gotten the size of the file and not used the BytesAvailable as the two won't necessarily match.
R RBeaubien Member Licensed User Longtime User Dec 23, 2011 #3 Ok, I'm now having an issue with the Base64 Encoding. I encode it with the String Utilities, send it to the web site, however, in VB.NET, when I try to decode it, it tells me that it has an invalid length for a Base64 char array. Any ideas? Upvote 0
Ok, I'm now having an issue with the Base64 Encoding. I encode it with the String Utilities, send it to the web site, however, in VB.NET, when I try to decode it, it tells me that it has an invalid length for a Base64 char array. Any ideas?
Erel B4X founder Staff member Licensed User Longtime User Dec 25, 2011 #4 Can you post the exact error message? Upvote 0
R RBeaubien Member Licensed User Longtime User Dec 27, 2011 #5 Ok, got past that issue. Had to make the Base64 URL Safe... Upvote 0