Upload image from stack to database using php webservice
Posted: Thu Sep 10, 2015 8:07 am
				
				Hello!
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 in livecode :
This methode don't working when I want to upload a picture to database.
Thank you!
Regards!
Razvan.
			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 takeimagewebThank you!
Regards!
Razvan.