files

Handling of public and private files in Drupal

20 MAR 2008 / joeri poesen

This article relates to Drupal 5.x

Drupal can handle public and private files. It’s quite good at this. However, when displaying a link to your files, there’s something you should be aware of:

Do not:

<?php 
  print l('somefile', $node->files[0]->filepath); 
?>

Do:

<?php 
  print l('somefile', file_create_url($node->files[0]->filepath)); 
?>

The former will work as long as Drupal’s file system is set to public. Once set to private, it will make you cry.

keywords:
Syndicate content