ios上传base64图片的问题
function image($image){$imageName = “20188_” . date(“His”, time()) . “_” . rand(1111, 9999) . ‘.png’;$image = str_replace(" ","+",$image);if (strstr($image, ",")) {$image = explode(',', $ima...
·
function image($image)
{
$imageName = “20188_” . date(“His”, time()) . “_” . rand(1111, 9999) . ‘.png’;
$image = str_replace(" ","+",$image);
if (strstr($image, ",")) {
$image = explode(',', $image);
$image = $image[1];
}
$path = "./" . 'uploads/Ver/' . date("Ymd", time());
if (!is_dir($path)) { //判断目录是否存在 不存在就创建
mkdir($path, 0777, true);
}
$imageSrc = $path . "/" . $imageName; //图片名字
$r = file_put_contents($imageSrc, base64_decode($image));//返回的是字节数
if (!$r) {
return 1;
} else {
return $imageSrc;
}
}
更多推荐
已为社区贡献1条内容
所有评论(0)