替换目录路径Drupal 6.20

时间:2011-06-27 21:37:52

标签: drupal drupal-6

我尝试在我指定的路径中保护我从表单保存的文件。我使用file_directory_path返回默认路径,如何更改路径或修改路径以使其个性化?

这样做的代码但它不起作用

 $filepath='/sites/ficheros_profesores';
//   str_replace(file_directory_path(),'',$filepath); 
     $file = file_save_upload('test',null,file_directory_path());
     file_set_status($file, FILE_STATUS_PERMANENT);

由于

1 个答案:

答案 0 :(得分:2)

如果我理解正确,您试图将上传的文件保存在默认“文件”目录中的文件夹中,不是吗?

相反str_replace,你可以用'。'连接字符串。简单地:

$file = file_save_upload('test',null,file_directory_path().'/sites/ficheros_profesores');

然后你应该确保'/ sites / ficheros_profesores /'存在并且'www-data'用户(假设linux)具有适当的权限。

希望它有所帮助。