php智能判断图片是否上传过,上传过直接返回图片地址简单逻辑
通过php核心函数hash_file实现
简单逻辑
图片上传前先查数据库的数据是否有,如
先对要上传的本地图片hash_file加密
$file_info['md5'] = hash_file('md5', $filename);
在查数据库数据是否存在,存在就返回数据表存在的地址
if ($file_exists = Attachment_Model::get(['md5' => $file_info['md5']])) { unlink($filename); $localpath = $file_exists['path']; }