2016-10-01 19 views
0

我試圖從$_FILES數組上傳文件。但在drupal7中出現錯誤。

The specified file temporary://fileOYnPHK could not be copied, because the destination directory is not properly configured. 
This may be caused by a problem with file or directory permissions. More information is available in the system log. 

sites/default/files有權777

這裏是我的代碼

if($_FILES['files']['name']['field_tenant_review_ref_und_form_field_tenancy_document_und_0']){ 
    $file_path = file_save_data(file_get_contents($_FILES['files']['tmp_name']['field_tenant_review_ref_und_form_field_tenancy_document_und_0']), 
    'public://sites/default/files/'.$_FILES['files']['name']['field_tenant_review_ref_und_form_field_tenancy_document_und_0']); 
    } 
    //$tenant_review->field_tenancy_document->file->set($file_path); 

是否有任何代碼的錯誤?請建議。

回答

1
'public://sites/default/files/' 

也許應該改爲

'public://' 

,因爲它probaby已經包含sites/default/files路徑,如果路徑在Drupal設置爲公開的文件路徑設置。

編輯: 出於安全考慮,文件夾的權限應設置爲775的最寬容。

相關問題