Hi Guys,
Need some help with an SQL statement. What I would like to is:
1. Check to see if a node has an attachment.
2. If the node does have an attached file, Return the filepath and filename in such a way I can assign a variable to each.
As far as I can see from the upload.module. this is the sQL that checks and loads the node attachments. What I need help with is the end of this snippet...i.e. after building the list of attachments..I would like to assign those to variables....i.e.
$att1="/full/file/path/and/filename.one"
$att2="/full/file/path/and/filename.two" etc.
But my php skills are limited and I'm not sure how to do that.
Anyone got any tips?
if ($node->files && user_access('view uploaded files')) {
$header = array(t('Attachment'), t('Size'));
$rows = array();
$previews = array();
// Build list of attached files
foreach ($node->files as $file) {
if ($file->list) {
$rows[] = array(
'<a href="/'. ($file->fid ? file_create_url($file->filepath) : url(file_create_filename($file->filename, file_create_path()))) . '">'. $file->filename .'</a>',
format_size($file->filesize)
);
// We save the list of files still in preview for later
if (!$file->fid) {
$previews[] = $file;
}
}
Dub..