I'am beginner in programing and I want to learn how can I put a image from my app in livecode, into database (blob type), using php webservice?
For take picture from database it's working with this function in php which call in livecode :
Code: Select all
<?php
/**
* @mainpage
* This documentation provides information about the API.
*
* More Information about Doxygen can be found here:
/**
* @file index.php
* @brief Main part of the web service
* @date Jul 16, 2015
* @author Nicola Liebi <nicola.liebi@patrickliebi.ch>
*/
require 'db.php';
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
// Initialize App
$app = new \Slim\Slim();
// URL Routing
$app->get('/image/:id','getImage');
// Run App
$app->run();
/**
* GET link/api_razvan/image/:ID
*
* Get image by id
*
* @return ID
*/
function getImage($id) {
try {
$link = mysqli_connect("localhost", "XXXXXX", "XXXXXXX","XXXXXX");
$sql = "SELECT picture FROM testObject WHERE oID=$id";
$res = mysqli_query($link,$sql);
if($res)
{
$row = mysqli_fetch_assoc($res);
echo $row['picture'];
}
} catch(PDOException $e) {
echo '{"error":{"text":'. $e->getMessage() .'}}';
}
}
code in livecode :
Code: Select all
on takeimageweb
global tIDimage
if tIDimage is a integer or tIDimage is not empty
then
put "link/api_razvan/image/"& tidImage into temp
put url temp into tImage
set the text of image "imagecontainer" to tImage
else
answer "No row selected!"
end if
if tImage is empty
then
answer "Picture not found!"
end if
end takeimageweb
Thank you!
Regards!
Razvan.