base64图像php未定义索引

时间:2016-01-04 22:59:18

标签: javascript php jquery image

我一直在用这段代码搜索base64解码错误:

define('UPLOAD_DIR', '../../imagenes/articulos/');
$imgFinal = (isset($_POST['imagen']) ? $_POST['imagen'] : null);
$img = str_replace('data:image/png;base64,', '', $imgFinal);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . '.png';
$success = file_put_contents($file, $data);
print $success ? $file : 'Unable to save the file.';

我使用了很棒的裁剪器,可以找到here。上面的代码在某些照片中效果很好,但在其他一些照片中说undefined index: imagen

所以,在一些照片作品中,在另一张作品中,不要......所以,任何想法?非常感谢。

0 个答案:

没有答案