Upload An Image Ionic 4

Hi everyone. I was trying to upload screenshoot image from my device to database. I get the image using the camera plugins and the image type is DestinationType.FILE_URI

To display the image on the device screen the image need to be converted using webView.convertFileSrc()

Finally, I tried to upload my image to the database using the camera.getPicture() function results, which is a FILE_URI, but my error log says

“error”:{“code”:9,“message”:“Failed generating the SQL query.”,“query”:"INSERT INTO bukti_pembayaran (bukti, created_on, created_by) VALUES (‘file:///storage/emulated/0/Android/data/com.consumpeApi.app/cache/Screenshot_2019-10-17-23-53-29-56.png?1571644761127’, ‘2019-10-21 07:59:24’, ‘0’)

I also tried to upload image that has been converted by the convertFileSrc() function and the error log says:

“error”:{“code”:9,“message”:“Failed generating the SQL query.”,“query”:"INSERT INTO bukti_pembayaran (bukti, created_on, created_by) VALUES (‘http://localhost/app_file/storage/emulated/0/Android/data/com.consumpeApi.app/cache/Screenshot_2019-10-17-23-53-29-56.png?1571644761127’, ‘2019-10-21 07:59:24’, ‘0’)

can someone tell me what I should do? Thank You!

try saving or capturing the mage in base64 format

What data type is “bukti”

Who wrote the server API, you need to speak to them to find out how you are meant to post the data.

3 Likes