从根目录以外上传图像在根目录的文件夹
问题描述:
我有文件夹结构这样从根目录以外上传图像在根目录的文件夹
public_html
/images
outside
/file_uploader.php
即,public_html
是根目录的文件夹。
outside
位于webroot文件夹之外。
所以,我想上传文件夹public_html/images
。
我在文件outside/file_uploader.php
这个代码:
move_uploaded_file(
$_FILES['img_name']['tmp_name'],
absolute/path/to/public_html/images/folder
);
但这返回错误,那Unable to access to public_html/images
文件夹。
问题:如何从outside_of_webroot_file
上传文件在webroot\folder
?
答
// see if you have permission to write to this folder
if(!is_writable(absolute/path/to/..)) {
chmod()
}
move_uploaded_file()
这是文件系统权限的问题。如果你在linux上看看web用户是否有权在文件夹“images”中写入 – Liutas