Just wondering can anyone tell me how to access the file field variable in drupal? I can access the rest of the node's variabels with the following php:
$node->field_event[0]['value'];
But I do not know how to access the content of a file field called field_pdf.
I know it is created with something like:
$node->field_pdf = array(
array(
'fid' => $file->fid,
'title' => basename($file->filename),
'filename' => $file->filename,
'filepath' => $file->filepath,
'filesize' => $file->filesize,
'mimetype' => $mime,
'description' => basename($file->filename),
'list' => 1,
),
);
I solved thie problem with the following snippet:
$node->field_pdf[0]['filepath'];
Hope this helps somebody.
j
Best Answer
I am not 100% sure I got what your doubt is, however on a node with a file_field (a series of PDF attachments in my case) the
$node
object has a property calledfiles
which structure is like this:I also suggest you install drupalforfirebug this is an awesome module that - in combination with firebug - allows you to see the structure of all your nodes / forms / user objects, etc... very handy!
HTH.
PS: If this is not what you are looking for, please specify in a comment how can I help better.