An OSTraining member asked how he could attach files such as PDFs, Excel Documents, Word Documents to his content.
There are many ways to do this in Drupal, but the easiest approach is to use the “File” field.
- Login to your Drupal site.
- Go to Structure > Content types.
- You either add the field to an existing content type, or you can create a new one for specifically adding the files:
Now you add a field to the content type.
- Click the blue “Add field” button.
- For the field type, choose “File”.
- Give the field a meaningful label such as “attached file”.
- In the field settings, make sure the “Enable Display field” and “Fields displayed by default” options are selected:
It is important to make sure that you have added all the required file formats. In this example I will only be using PDF, but you can add as many file extensions you wish here.
When it comes to the size of file uploads, the maximum upload size is controlled by your server. Often, servers do not allow file uploads larger than 8MB. You will need to check your PHP settings if you want to increase the size of files that can be uploaded.
Now you have configured the content type, you can upload the files.
- Go to Content > Add content.
- Upload a file using the field that you created.
- Your file will show on the front of the site:
You can also change the display of the file:
- Go to Structure > Content types > Manage display.