1

我们有一个允许用户上传文件的基本表单。表单有一个<input type="file">,在做一些验证后,我们保存文件如下:

    if($file_upload) {
        // this is a file that we can upload and manage
        rename($_FILES['file']['tmp_name'], ABSPATH . 'path/to/files/file_' . $user_resume_record_id[0]->id . '.' . $file_extension);

}

保存文件的父方向的权限为 755。由于某种原因,我们上传的新文件以 600 的权限到达,因此用户以后看不到它们。我们做错了什么?

4

1 回答 1

1

您最好使用move_uploaded_file(),这适用于这种精确情况。

此外,这已在 PHP 手册(链接此处)中报告,建议的解决方案是使用 chmod() 或 copy()

于 2013-02-24T19:03:55.080 回答