I have a database named \'mysqlproject\' that contains two tables. One of the tables that i am interesting in is named markers and declared in database like this :
Found it!
define('UPLOAD_DIR', 'EventImages/');
$img = $_POST['imgBase64'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . '.png';
$success = file_put_contents($file, $data);
print $success ? $file : 'Unable to save the file.';
$result=mysql_query("SELECT id FROM markers ORDER BY id DESC LIMIT 1");
while ($row = mysql_fetch_array($result)){
$LastInsertID=$row['id'];
}
$results = mysql_query("UPDATE markers SET PhotosEvent='".$file."' WHERE id = '".$LastInsertID."'");
now it works ok.. I am fetcing the last known id that is in table Markers and i save the image's url that is stored in variable $file in the database!! I also save the image to folder EventImages as i did before!!