Update the file to a newer version
Here, we’ll explain the best way to replace a file with a newer version without changing the file name or links.
Link to the file correctly
To avoid problems with broken links when you replace a file, we recommend that you link to the media object itself rather than linking directly to the file’s URL.
When you upload a file in Drupal, your file becomes part of what is known as a "media object". This media object contains the media name, the file itself and any file tags.
You can link to the media object by searching for its name using the link tool (the link tool with the plus sign). The link might then look like this, for example: "/media/222".
If there are several media objects with the same name, you can enter the correct node ID yourself (the number at the end; in the example above, the node ID is "222"). You can find the node ID by, for example, going to Content > Files and media > List all media and locating the media object. When you hover your mouse over the media name (in Chrome or Firefox, for example), you will see the media object’s URL at the bottom left of the browser. The number you see at the end is the node ID.
Here, we’ll explain the best way to replace a file with a newer version without changing the file name or links.
Link to the file correctly
To avoid problems with broken links when you replace a file, we recommend that you link to the media object itself rather than linking directly to the file’s URL.
When you upload a file in Drupal, your file becomes part of what is known as a "media object". This media object contains the media name, the file itself and any file tags.
You can link to the media object by searching for its name using the link tool (the link tool with the plus sign). The link might then look like this, for example: "/media/222".
If there are several media objects with the same name, you can enter the correct node ID yourself (the number at the end; in the example above, the node ID is "222"). You can find the node ID by, for example, going to Content > Files and media > List all media and locating the media object. When you hover your mouse over the media name (in Chrome or Firefox, for example), you will see the media object’s URL at the bottom left of the browser. The number you see at the end is the node ID.
Replace file
- Add the new version of the file
- Go to Content > Files and media > List all Media
- Find the media item for which you want to change the file.
- Tap Edit to access the media item’s edit mode.
- Tap 'Remove' next to the file to delete the existing file.
- Select the new file under "Select file"
- Tap Save
Delete the old version of the file (site admin only)
- Go to Content > Files and media > List all Files (Only Site Admins can access this)
- Find the file you want to delete.
- Press Delete
- Tick both options and select 'Delete media file'
There should now be a new version of the file, and links to the media object will now point to the new file. However, the old version of the file remains in Drupal for at least 6 hours before being permanently deleted, which means a number is added to the end of the new file’s filename (in the event that both files had identical filenames). If you do not want a number added to the end, the old file must be completely deleted from the system before the new one is added. Only users with "Site admin" permissions can do this.