How to upload Magento 2 Product Attachments

How to Download and Upload Product Attachment Files in Magento 2?

Anmol Lohana

How to Download and Upload Product Attachment Files in Magento 2?

How to upload Magento 2 Product Attachments

Table of Contents

While the default Magento page can display all kinds of product information, there are cases where you might want to provide more information (for example, user manuals, technical specs, etc.).

Consequently, it becomes crucial for Magento stores to link files to such product pages. This can be accomplished by displaying an appealing icon and an informative document, capturing guests’ attention and encouraging them to proceed with the checkout process.

The Magento admin is responsible for providing additional user instructions, documentation, photos, and videos related to specific products.

However, by default, Magento does not permit customers to upload files from the backend. Instead, customers can swiftly download associated Magento 2 product attachments from the front end. Furthermore, keeping your product content concise and attaching relevant files allows consumers to access all the necessary information in one place and download it if needed.

Various methods exist to upload product attachments for your customers, such as utilizing Magento Extensions or programmatically uploading files in Magento 2 through system configuration.

If you want to learn about creating products, then check this guide on how to manage products in Magento.

Adding Magento 2 Product Attachments Using Extensions

Configure Product Attachments in Magento 2 using these three extensions:

Magento 2 Product Attachments by MageComp

When selling compound products, it is common for your shop visitors to seek comprehensive information that can help them make informed purchasing decisions. Clients may require manuals or attachments that cannot be adequately described in the product description.

MageComp’s Product Attachment Extension for Magento 2 stores allows store owners to upload product attachments displayed on a separate tab in the front end. With this extension, the admin can modify the title of the attachment tab in the front end and upload files to the Magento 2 store.


  • Separate tab display for attachments.
  • Ability to upload attachments using the backend admin area.
  • Backend configuration for managing allowed file type extensions.
  • Support PDFs, Excel, documents, images, and various media types.
  • Compatibility with Magento versions 2.1, 2.2, 2.3, and 2.4.


  • The Product Attachment Extension is available for $49.
  • It comes with a 30-day money-back guarantee.
  • Lifetime free upgrades are included.
  • Users will also receive 90 days of free support.


  • After installing the extension, navigate to Stores > Configuration to access the settings.
  • Under the Product Attachments option, you can turn the extension on or off.
  • Select “YES” for “Show Attachments On Product Detail” to display attachments on the front end.
  • Similarly, select “YES” for “Show on Product Tab” to display the attachments on the product tab.
  • In the Manage Product Attachments section, you can add/create new attachments or view existing ones.
  • To add a new attachment, click “Add New” and provide the relevant details, as shown in the screenshot below. Ensure the status is set to “YES” and click “Save and Continue Edit” to display the attachments to your visitors.
  • To enable the attachment for a specific product, click on the “Select Products” option and save your changes.
  • The uploaded file in the Magento 2 store can be seen as depicted below, and customers can also download the attachment.

That’s all you need to do!

Product Attachment Extension for Magento 2 by Mconnect

The Product Attachment Extension for Magento 2 by Mconnect Media simplifies the process of uploading and downloading attachments for Magento store owners. 

This extension enables you to provide yours customers with additional information about your products/services through downloadable file attachments. It allows you to display user guides, tutorials, privacy policies, and other relevant materials on the front end of your Magento 2 store.


  • Attachments are displayed in a separate tab-based list view on the front end.
  • Backend grid for efficient management of uploaded files.
  • Auto-detection of file types with corresponding icons, titles, and sizes.
  • Each product can have an unlimited number of attachments.
  • Ability to upload any file type and assign it to specific products using the grid.
  • AJAX technology enables the uploading of multiple files without page reload.
  • Customization of file visibility based on specified shop views and customer groups.
  • Provision of additional information to customers through videos, tutorials, photos, documents, PowerPoint presentations, and more.
  • Magento Community Versions: 2.0.x, 2.1.x, 2.2.x, 2.3.x, 2.4.x.


  • The Product Attachment Extension is priced at $79.
  • It comes with a 30-day money-back guarantee.
  • Lifetime free upgrades are included.
  • Users will receive 90 days of free support.


  • Login to the admin panel of your Magento 2 store and navigate to Store > Configuration > M-Connect > Product File Upload.
  • Enter the License and Serial Key provided in the zip file.
  • Go to General Settings.
  • Choose “Yes” or “No” to turn the extension on or off.
  • Specify the allowable file extensions in the “Allowable File Extensions” field.
  • Select “Yes” or “No” to allow or deny file downloads for non-logged-in users.
  • Set the “Redirect to Referrer Page after login” option to “Yes” or “No” to determine whether users will be redirected to the previous page after successful login.
  • Enter custom text for a successful login.
  • Go to M-Connect Media in the left category and select “Manage Product File Upload.”
  • Click the “Add New” button and open a new window.
  • In the General Information section, enter the file name, add the product image, and set the status to “Enable” to display the product image.
  • In Store Views, select the store from the drop-down where you want to display the image and downloadable file.
  • In the Products section, you can choose the number of products you want to assign the file simultaneously. Then click on “Save.”
Product Attachments for Magento 2 by MagePlaza

Mageplaza is a Magento 2 extensions provider site, it offers product attachment extension that enhances the functionality of product pages in e-commerce stores. This extension enables online business owners to attach various files to their product pages, providing valuable information and resources to customers.

The Mageplaza Product Attachment extension features include multiple file formats, easy management, customizable icons, customer permissions, frontend display, SEO-friendly content, and improved user experience. By offering relevant and valuable files for download, Magento 2 store owners can enhance the shopping experience for their customer and build trust with customers, and facilitate informed purchase decisions.


  • Ability to attach single or multiple files to a product.
  • An unlimited number of attachments.
  • Drag and drop feature for easy file upload.
  • Option to add multiple CSV files.
  • Configuration of file visibility on specific store views.
  • Ability to hide attachments from non-login customers.
  • Display attachments in a separate tab-based list view on the front end.
  • Ability to attach any URL on the products, such as YouTube, Dropbox, Google Drive, or any other link.
  • Provision of 40 icon packages for automatic identification of attachment formats.
  • Compatible with CE/EE/B2B/Cloud/Adobe Commerce 2.2.x, 2.3.x, 2.4.x versions.


  • The cost of Product Attachments for Magento 2 is $129.
  • 60-day money-back guarantee.
  • Free upgrades for a lifetime.
  • Receive 365 days of support.


To configure Product Attachments for Magento 2, follow these steps:

  • Log in to the Magento 2 admin panel and navigate to Catalog > Product Attachments > Configuration.

On the next page, follow the instructions below:


  • Enable: Select “Yes.”
  • Block Title: Enter the title of the attachment.
  • Show On: Choose the positions to display Product Attachments, such as in the Product Tabs, under the Add to Cart button, Sidebar, or all.
  • Display Attachment File Size: Optional setting to display the file size.
  • File Size Limit Allowed (MB): Attachment files must be below 25MB to be sent via Gmail.
  • Add Attachments in Order Emails: Select “Yes” to include attachments in order emails.
  • Groups: Attachments are displayed on the front end in a separate tab-based list view.

The settings selected in this area serve as the default value when uploading a product attachment. These settings are initially applied when adding new files, but the admin can modify them when editing or adding new files.


Navigate to Catalog > Product Attachments > Manage Files.

  • Admins can view essential information about each file in the grid, including the ID, Label, Name, Status, Store View, Customer Group, Group, Priority, Create Date, and Action.
  • Admins can perform actions such as deletion by selecting the file and choosing “Action/Delete” in the Action Dialog. A confirmation pop-up will appear, and clicking “OK” will proceed with the deletion.
  • To update file information, admins can click “Edit” in the Action column.
  • Additionally, admins can filter, change the store view, show/hide columns, and export the grid.

Add New/Edit Form

Download and Upload files in Magento 2 by System Configuration

Download and upload files in Magento 2 programmatically by system configuration.

Magento 2 File Upload Programmatically

To provide users with a comprehensive understanding of a product’s appearance and functionality, it is necessary to include multiple photos and files, such as product images from different angles, videos, user guides, size charts, tutorials, privacy policies, and terms of service, among others.

You have two options for uploading files in Magento 2: use the previously mentioned extensions or utilize the code below within a custom module to programmatically upload files.

There are two methods for programmatically uploading files:

  • Create an input file field.
  • The controller will receive the request and save the files.

Below is the HTML code for the input file field:

<input type="file" name="upload_custom_file" id="upload_custom_file" title="Upload Custom File" class="input-text" data-validate="{required:true}">

And here is an example of the controller class file code:

namespace VendorName\ModuleName\Controller;

use Magento\Framework\App\Action\Context;
use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\Filesystem;
use Magento\MediaStorage\Model\File\UploaderFactory;
class YourController extends \Magento\Framework\App\Action\Action

protected $messageManager;
protected $filesystem;
protected $fileUploader;

public function __construct(
Context $context,
ManagerInterface $messageManager,
Filesystem $filesystem,
UploaderFactory $fileUploader
$this->messageManager = $messageManager;
$this->filesystem = $filesystem;
$this->fileUploader = $fileUploader;

$this->mediaDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);


public function execute()
// your code

$uploadedFile = $this->uploadFile();

// your code

public function uploadFile()
// this folder will be created inside the "pub/media" folder
$yourFolderName = 'your-custom-folder/';

// "upload_custom_file" is the HTML input file name
$yourInputFileName = 'upload_custom_file';

$file = $this->getRequest()->getFiles($yourInputFileName);
$fileName = ($file && array_key_exists('name', $file)) ? $file['name'] : null;

if ($file && $fileName) {
$target = $this->mediaDirectory->getAbsolutePath($yourFolderName);

/** @var $uploader \Magento\MediaStorage\Model\File\Uploader */
$uploader = $this->fileUploader->create(['fileId' => $yourInputFileName]);

//Set allowed file extensions
$uploader->setAllowedExtensions(['jpg', 'pdf', 'doc', 'png', 'zip']);

// allow folder creation

// rename file name if it already exists

//Upload the file to the specified folder
$result = $uploader->save($target);

//echo '<pre>'; print_r($result); exit;

if ($result['file']) {
$this->messageManager->addSuccess(__('File has been successfully uploaded.'));

return $target . $uploader->getUploadedFileName();
} catch (\Exception $e) {

return false;

These steps provide a straightforward approach to programmatically uploading files in Magento 2.

Magento 2 File Download Programmatically

Various file types are supported, including CSV files, PNG/JPG images, videos, and PDF files. You can download the file at any time if it is permitted. You can utilize the provided code if you want to apply the same functionality to a personalized page.

Copy and paste it into your controller below the existing code.


namespace MageDelight\Helloworld\Controller\Index;

use Magento\Framework\App\Filesystem\DirectoryList;

class Index extends \Magento\Framework\App\Action\Action
* @var \Magento\Framework\App\Response\Http\FileFactory
protected $fileFactory;

* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\App\Response\Http\FileFactory $fileFactory
) {
$this->fileFactory = $fileFactory;

public function execute()
$filePath = 'media/md_product_print/logo.svg';
$downloadName = 'logo1.svg';
$content['type'] = 'filename';
$content['value'] = $filePath;
$content['rm'] = 0; // If you will set here 1 then, it will remove the file from the location.
return $this->fileFactory->create($downloadName, $content, DirectoryList::PUB);

Inject the following class: Magento\Framework\App\Response\Http\FileFactory into your file and add the execute() method within the method’s logic.

In the create() method, the first argument should be the desired file name for downloading, the second argument should be an output array for the file, and the third argument should be the directory path from which the download file is desired. For the file path, add the pub/media image path here. You can use DirectoryList::PUB to retrieve the file from the pub directory as the directory path.

Remember to clean the cache before proceeding with the action.


In conclusion, downloading and uploading files or configuring Magento 2 product attachments can be done through two main methods: using extensions or configuring the system settings programmatically.

By combining the power of extensions and programmatically configuring system settings, Magento 2 provides users a versatile and efficient solution for downloading and uploading files. Whether users prefer ready-made extensions or a more customized approach, Magento 2 offers a robust platform for handling files in an e-commerce environment.

If you are looking for a fast and secure cloud hosting platform for your store, check out Devrims Managed Magento Hosting.

Share it!

Share it!

Start Creating Web Apps on Managed Devrims Cloud Server Now

Easy Web Deployment for Agencies, Developers and e-commerce Industry.

There's More To Read