我已经实现了三个php脚本,其中两个是在stackoverflow上提出的,用于解决较大图像的base64_decode无效的问题。在这一点上,我放弃了PHP脚本,我只是想知道可能需要哪些服务器升级才能使其工作。所有三个都在一台服务器上以任何分辨率工作,但在另一台服务器上,获得的最大分辨率约为1680 x 800(文件大小约为140 kb)。除此之外,它失败并输出一个空图像(文件大小为0 kb)。数据从Flash应用程序发布。我可以在两台服务器之间看到的唯一区别是php内存限制(256 MB对128 MB)。这可能吗?谢谢你的任何建议!
尝试的php脚本复制如下:
版本1:
$png = base64_decode($_POST['imagedata']);
header('Content-Type: image/png');
header("Content-Disposition: attachment; filename=".$_GET['name']);
echo $png;
版本2:
$encoded = $_POST['imagedata'];
$decoded = "";
for ($i=0; $i < ceil(strlen($encoded)/256); $i++)
$decoded = $decoded . base64_decode(substr($encoded,$i*256,256));
header('Connection: Keep-alive');
header('Content-Type: image/png');
header("Content-Disposition: attachment; filename=".$_GET['name']);
echo $decoded;
版本3:
$data = $_POST['imagedata'];
$target = 'img_'.date('Y-m-d-H-s').'.png';
$whandle = fopen($target,'w');
stream_filter_append($whandle, 'convert.base64-decode',STREAM_FILTER_WRITE);
fwrite($whandle,$data);
fclose($whandle);
header("Content-Length: " . filesize($target));
header("Content-Disposition: attachment; filename=" . basename($target));
readfile($target);
unlink($target);
答案 0 :(得分:2)
可能与内存有关的问题:帖子大小限制或php内存使用限制。