php - Saving cropped image on the server -


the image has been saved on server when download , it"s format not appropirate , not opening, if got know answer regarding this.

<?php     define('upload_dir', 'uploads/');     $img = $_post['img'];     $img = str_replace('data:image/png;base64,', '', $img);     $img = str_replace(' ', '+', $img);     $data = base64_decode($img);     $file = upload_dir . uniqid() . '.jpg';     $success = file_put_contents($file, $data);     print $success ? $file : 'unable save file.'; ?> 

and js code

$.ajax({         type: "post",         url: "save.php",         data: {'img': encodeuricomponent(result.src)},         contenttype: "application/x-www-form-urlencoded;charset=utf-8",         success: function(data){        }       });     } 


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -