我需要一些帮助来将图像放在用户创建的“AD”上。我正在使用 JSON、Android、PHP 和 MySql
add_ad.php
<?php
//load and connect to MySQL database stuff
require("config.inc.php");
if (!empty($_POST)) {
//initial query
$query = "INSERT INTO ads ( ad_title, ad_price, ad_category, ad_description, ad_user, ad_contact ) VALUES ( :title, :price, :category, :description, :email, :mobile ) ";
//Update query
$query_params = array(
':title' => $_POST['ad_title'],
':price' => $_POST['ad_price'],
':category' => $_POST['ad_category'],
':description' => $_POST['ad_description'],
':email' => $_POST['ad_user'],
':mobile' => $_POST['ad_contact']
);
//execute query
try {
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch (PDOException $ex) {
// For testing, you could use a die and message.
//die("Failed to run query: " . $ex->getMessage());
//or just use this use this one:
$response["success"] = 0;
$response["message"] = "Erro base de dados. Impossível adicionar o anúncio.";
die(json_encode($response));
}
$response["success"] = 1;
$response["message"] = "Anúncio criado com sucesso! Aguarde aprovação.";
echo json_encode($response);
} ?>
我不知道如何转换它以从 android 接收图像并将其保存在服务器/数据库上,请告诉我数据库上字段的类型。
这非常重要,之后我需要将图像从我的 android 发送到这个 .php 并将其保存在该用户身上。
谢谢,请注意我是android新手,所以要勇敢:)