我有一个脚本,该脚本可以移动文件,然后尝试获取文件以生成缩略图。但是,它总是说该文件不存在。如果我在脚本执行后在文件上尝试file_exists()
,似乎可以找到它。
我的代码片段:
// Move file, returns a path e.g. "\home\sambam\public_html\sa\storage\files\0\rxugn7OXoHNRY4J.mp4"
// This also sets file permissions to 0755
$source = $fs->move_from_tmp($filename);
// clear cache
clearstatcache(true);
// Now file_exists returns false
if(file_exists($source)){
// generate thumbnail;
}
从发件人移动:
public function move_from_tmp($filename){
// $this->tmp_folder = /home/sambam/public_html/ss/storage/tmp
// this->folder = /home/sambam/public_html/ss/storage/files/0
if(!is_readable($this->tmp_folder.self::DS.$filename)){ chmod($this->tmp_folder.self::DS.$filename, 0755); }
$ext = strtolower(pathinfo(basename($filename), PATHINFO_EXTENSION));
$new_filename = pathinfo($filename, PATHINFO_FILENAME);
// Move file
if(rename($this->tmp_folder.self::DS.$filename, $this->folder.self::DS.$new_filename.".".$ext)){
return $this->folder.self::DS.$new_filename.".".$ext;
}else{
return false;
}
}
这在Windows的本地计算机上有效,但在Linux CentO的生产计算机上似乎无效。
我也尝试过: