我想将带有图像的数据发送到sql server。但不幸的是,我无法做到这一点。 当我推动两者(图像和数据)。服务器只接收图像。 请帮我这样做。
My js code
function uploadPhoto(imageURI) {
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
options.mimeType = "image/jpeg";
console.log(options.fileName);
var params = new Object();
params.value1 = "sheshant";
params.value2 = "param";
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
ft.upload(imageURI, "http://192.168.1.100/taxi/upload/upload.php",
function(result){
console.log(JSON.stringify(result));
}, function(error){
console.log(JSON.stringify(error));
}, options);
}
我的PHP代码
$name = $_FILES["file"]["name"];
$name2 = $_FILES["files"]["params"];
$tmp_name = $_FILES["file"]["tmp_name"];
if(!empty($name)){
move_uploaded_file($tmp_name,$name.".jpg");
}else{
echo "Please choose a file";
}
$sql7 ="INSERT INTO `image` (`image`) VALUES ('$name2')";
$result=mysqli_query($con,$sql7);