I wanna ask how can I post an image file to the MySQL using post method? Since what I did is only upload the file pathway and not the image.
my post request:
Future addProduct() async{
var url = 'http://10.0.2.2/foodsystem/addproduct.php';
http.post(url, body: {
"productname": controllerName.text,
"productprice": controllerPrice.text,
"producttype": controllerType.text,
"product_owner": globals.userId,
"image": _image.path,
//"image": _image.path.split('/').last,
});
my PHP code:
<?php
include 'conn.php';
$product_owner = $_POST['product_owner'];
$productname = $_POST['productname'];
$productprice = $_POST['productprice'];
$producttype = $_POST['producttype'];
$image = $_POST['image'];
//$realImage = base64_decode($image);
$connect->query("INSERT INTO product (product_name, product_price, product_type, product_owner, image) VALUES
('".$productname."','".$productprice."','".$producttype."','".$product_owner."','".$image."')")
?>
my MySQL table