Search code examples
phpdrupaldrupal-6

file path from sql query in drupal


I'm wanting to get the filepath ie /sites/default/files/myfile.pdf for my file uploads.

I'm using the below:

$row['node_data_field_factsheet_field_factsheet_data']

this returns a:1:{s:11:"description";s:0:"";}

How do i get the actual path?

Here is my sql statement:

SELECT node.nid AS nid,
node_data_field_factsheet.field_factsheet_fid AS node_data_field_factsheet_field_factsheet_fid,
node_data_field_factsheet.field_factsheet_list AS node_data_field_factsheet_field_factsheet_list,
node_data_field_factsheet.field_factsheet_data AS node_data_field_factsheet_field_factsheet_data,
node.type AS node_type,
node.vid AS node_vid
FROM node node
LEFT JOIN content_type_fund node_data_field_factsheet ON node.vid = node_data_field_factsheet.vid
WHERE node.type in ('fund')

Solution

  • You don't need to use SQL. Just call Drupal's file_create_path('myfile.pdf') function in the File API.