Is there any way to save received image in two places , One in original size in a folder and the other one in thumbnail size (90 , 120) in another folder using PHP . Aspect ratio of original images are (3 , 4) and I just need to change the size ...
Already my code is doing good and can save image in original size .
By the way images are sending from an android app.
here is the php code to save image in folder and insert data to table of database ...
<?php
if ($_SERVER["REQUEST_METHOD"]=="POST") {
require 'connection.php';
insertData();
}
function insertData(){
global $connect;
mysqli_set_charset($connect,"utf8");
$name = $_POST["name"];
$description = $_POST["description"];
$image = $_POST["image"];
$sql ="SELECT id FROM my_table ORDER BY name ASC";
$res = mysqli_query($connect,$sql);
$id = 0;
while($row = mysqli_fetch_array($res)){
$id = $row['id'];
}
$path = "img/$id.png";
$decoded_string = base64_decode($image);
$file = fopen($path, 'wb');
$is_written = fwrite($file, $decoded_string);
fclose($file);
$imgpath = "http://my-site.com/folder/$path";
if($is_written > 0) {
$query = "INSERT INTO my_table (path,name,description) VALUES ('$imgpath','$name','$description ')";
$result = mysqli_query($connect, $query) ;
if($result){
echo "success";
}else{
echo "failed";
}
mysqli_close($connect);
}
}
?>