且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将图像发送到 MySQL 的 Android 应用程序

更新时间:2021-12-25 23:03:44

  <?php 
    $name = $_POST['image'];
     $entry = base64_decode($name);
     $image = imagecreatefromstring($entry);
     $directory = dirname(__FILE__).DIRECTORY_SEPARATOR."images/".DIRECTORY_SEPARATOR."index".$title.".jpeg";
     header ( 'Content-type:image/jpeg' );
     $imagetojpg=imagejpeg($image, $directory); 
     imagedestroy($image );      
     readfile ($directory);  
     exit ();
    ?>

这应该可以正常工作.image 是一个包含 base64 编码字符串的变量.

This should work fine.image is a variable which contain base64 encoded string.