Javascript 如何使用PDO将图像插入mysql数据库

Javascript 如何使用PDO将图像插入mysql数据库,javascript,php,api,pdo,Javascript,Php,Api,Pdo,我正在开发一个应用程序,可以在其中向数据库添加项目信息。要插入项目信息,我可以这样做。现在我想将图像添加到数据库中。在我的代码中,我有一个addFunction(),在这里我使用javascript调用api。 现在我想使用这个api将图像添加到mysql数据库中。我怎样才能做到呢 function addFunction(){ var usermemberno=document.getElementById(“usermemberno”); 变量描述=document.getElementB

我正在开发一个应用程序,可以在其中向数据库添加项目信息。要插入项目信息,我可以这样做。现在我想将图像添加到数据库中。在我的代码中,我有一个addFunction(),在这里我使用javascript调用api。 现在我想使用这个api将图像添加到mysql数据库中。我怎样才能做到呢

function addFunction(){
var usermemberno=document.getElementById(“usermemberno”);
变量描述=document.getElementById(“描述”);
var description2=document.getElementById(“description2”);
var ItemGroup=document.getElementById(“ItemGroup”);
var ItemType=document.getElementById(“ItemType”);
var StockControl=document.getElementById(“StockControl”);
var TaxType=document.getElementById(“TaxType”);
var IsActive=document.getElementById(“IsActive”);
var ItemBrand=document.getElementById(“ItemBrand”);
var ItemModel=document.getElementById(“ItemModel”);
var url='1〕http://localhost/E-CommerceAPI/AI_API_SERVER/Api/Item/CreateItemAPI.php';
风险值数据={
UserMememberNo:usermemberno.value,
Description:Description.value,
描述2:描述2.vale,
ItemGroup:ItemGroup.value,
ItemType:ItemType.value,
StockControl:StockControl.value,
TaxType:TaxType.value,
IsActive:IsActive.value,
ItemBrand:ItemBrand.value,
ItemModel:ItemModel.value
};
获取(url{
方法:“POST”,
正文:JSON.stringify(数据),
标题:{
“内容类型”:“应用程序/json”
}
}).then(res=>res.json())
.then(response=>console.log('Success:',JSON.stringify(response)))
.catch(error=>console.error('error:',error));
}

图1