2

当我转到使用 imagegd2() 生成的图像 URL 时,我收到“imagegd2():无法打开临时文件”错误消息,例如:

$image->make($data['path']);
$image->resize(100, null, true)->crop(70, 70);
// create response and add formated image
$response = Response::make($image->encode('png'));
// set content-type
$response->header('Content-Type', 'image/png');

它与权限和 OSX 有关,因为在 linux 开发环境中工作正常。

4

1 回答 1

6

我发现了问题,Mac OSx 临时文件夹类似于:/var/folders/6l/zy7_vl5n5kq8wbv00bvzc15h0000gn/T/

检查终端中的临时文件夹:

echo $TMPDIR

授予该文件夹的读取、写入和执行权限或 777,而不仅仅是 755:

chmod -R 777 [your_tmp_folder]

就这样!

于 2014-03-27T09:52:01.267 回答