使用move_uploaded_file移动文件后,文件将被锁定以防止进一步修改(例如重命名)。这是在我的本地服务器(localhost)上运行Ubuntu 14并使用Codeigniter框架。上传目录设置为777(我知道不好,但它对我的开发环境来说更容易)。这似乎没有在生产中发生。脚本完成后甚至在浏览器关闭后它们仍保持锁定状态。这是代码。
public function upload_photos($pid = '', $timestamp = 0, $files = array()) {
$uploadpath = $this->post_model->photo_upload_path($timestamp);
$count = 0;
foreach ($files as $file) {
$file["tmp_name"] !== '' ? $check = getimagesize($file["tmp_name"]) : $check = FALSE;
if ($check !== FALSE && $file["size"] <= MAX_PHOTO_SIZE) {
$target_file = $uploadpath . 'dd-' . $pid . '-' . $count . '.' . strtolower(end(explode('.', $file['name'])));
if (move_uploaded_file($file["tmp_name"], $target_file)) {
$count++;
}
}
}
return $count;
}