خرید بک لینک

currently i developing a mobile app that able to snap photo and save in server. I able to pass the image base64 data string to my php using AJAX. I also can decode the base64 data string to image, but caot save in my server. Every time i run my app, the result show that i already save my image into server but when i check in my server i didn't find it. I follow the example on https://xuri.me/2014/11/18/save-a-png-image-from-a-base64-data-string-with-php.html.

Below is my php code.

$img = $_POST['img'];
$img = str_replace('data:image/jpg;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$img_name = uniqid();
$file_name = $img_name . '.jpeg';
$file_path = realpath("../media/rewardreceipt/");
$file_path = $file_path . "/" . $file_name ;

if(file_put_contents($file_path , $data)) {
     $arr = array('result' =>$file_name);
     echo json_encode($arr);
} else{
    $arr = array('result' =>'false');
    echo json_encode($arr);
}

- - , .

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 12 اسفند 1394 ساعت: 15:49

صفحه بندی