Unable to upload file from $_FILES array in drupal7 I am trying to upload file from $_FILES array. but getting following error in 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.


The sites/default/files has permissions 777

Here is my code

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-&gt;field_tenancy_document-&gt;file-&gt;set($file_path);


Is there any mistake in code? Please suggest.
The problem is not with your Public file system path but with your Temporary directory; normally it is /tmp if you're in a Mac or Linux server.

You can check that the Temporary Directory is well configured, maybe it is pointing to a non-existing path.

To check the configuration in Drupal 7 you must go to Configuration > Media > File system.