function base64_img($base64_img){
/* $base64_string = $base64_img;
$savename = uniqid().'.jpeg';
$save_path = $php_path . 'Uploads/';
$ymd = date("Ymd");
$save_path .= $ymd . "/";
$save_url .= $ymd . "/";
if (!file_exists($save_path)) {
mkdir($save_path);
}
$savepath = $save_path . $savename;
$image = base64_to_img( $base64_string, $savepath );
return '/'.$image; */
$base64_string = $base64_img;
$base64_0=explode(',', $base64_string);
$base64_1=explode('/', $base64_0['0']);
$base64_2=explode(';', $base64_1['1']);
$s = base64_decode(str_replace(''.$base64_0['0'].',','',$base64_string));
$savename = uniqid().time().rand(10000,99999).'.'.$base64_2['0'];
$save_path = $php_path . 'Uploads/image/';
$ymd = date("Ymd");
$save_path .= $ymd . "/";
$save_url .= $ymd . "/";
if (!file_exists($save_path)) {
mkdir($save_path);
}
$savepath = $save_path . $savename;
$image= file_put_contents($savepath, $s);
return '/'.$savepath;
}
function base64_to_img( $base64_string, $output_file ) {
$ifp = fopen( $output_file, "wb" );
fwrite( $ifp, base64_decode( $base64_string) );
fclose( $ifp );
return( $output_file );
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。