There is a form ("Add car model"). I write in it for example: Model: Gelentvagen, Description: Cool jeep. And ship photo. I send it via POST to "process.php" in DB (Denver, php 5.2.12). In him:
$json=normJsonStr(json_encode($_POST)); // где, normJsonStr - это функция для отображения кириллицы. $sql = "INSERT INTO car_models (model_name, photo, opisanie, marka_id, json)values('$mod_name','$file_name','$opisanie', $marka_id, '$json')"; In the database, in the json field is inserted:
{"target":"add_model","model_name":"Гелентваген","opisanie":"Классный джип","marka_id":"11"}
A photo inside is not inserted!
Although in the usual field "photo" there is a photo of Gelentvagen!
How to make it appear in json'e?
Update
In a hurry, completely forgot! Sorry!
The photo comes to the database through $_FILES .
$mod_name=@$_POST['model_name']; $opisanie=@$_POST['opisanie']; $marka_id=@$_POST['marka_id']; $json=normJsonStr(json_encode($_POST)); $file_name=null; $file_error=@$_FILES['photo_file']['error']; if($file_error==0){ $file_name=@$_FILES['photo_file']['name']; $file_tmp_name=@$_FILES['photo_file']['tmp_name']; move_uploaded_file($file_tmp_name,"../uploads/$file_name"); } Where at the output he gets $file_name - which is inserted into the INSERT. Therefore, it does not cling. Now I try to combine them - it does not work.
Maybe you have thoughts?