【发布时间】:2013-01-01 04:07:46
【问题描述】:
上传图片时,我将原始图片路径(包含的文件名)存储在db中。
For example:
img/uploaded/photo.jpg
然后我生成它的缩略图并存储在下面的目录中,而不是在 db 中。
/img/uploaded/thumbs/photo_thumb.jpg
我有以下功能,但不知道如何获取属于 db 中 url 的拇指。
//ie: $file is img/uploaded/photo.jpg
public function get_thumb($file)
{
//get the path without filename
$get_path = dirname($file) . "/thumbs/";
//result img/uploaded/thumbs/ (how can i get the photo_thumb.jpg) here?
return $get_path;
}
编辑 basename($file) 从路径中获取文件名,但是如何添加 _thumb.jpg?
【问题讨论】:
-
你能指定你正在使用的语言吗(也许将它添加为标签)?我无法确定这是否是 JavaScript、Perl、PHP ......并且
dirname函数存在于所有列出的三个中。你需要一个字符串操作,不同的语言有不同的可能性。 -
这是codeigniter (php)。我添加了 php 标签。
-
有了大拇指你想做什么?
-
@chris 为观众显示缩略图而不是使用大图
-
所以您将文件名存储在 db yeh 的字段中?
标签: php codeigniter thumbnails