To make PrestaShop 1.7 accept SVG (Scalable Vector Graphics) format for image uploads

najm

New member
XNullUser
Joined
Jul 6, 2021
Messages
16
Reaction score
3
Points
3
NullCash
137
To make PrestaShop 1.7 accept SVG (Scalable Vector Graphics) format for image uploads, you'll need to make modifications to PrestaShop's configuration. By default, PrestaShop doesn't allow SVG uploads for security reasons, as SVG files can contain potentially harmful code.

Here's a JavaScript code snippet you can use to enable SVG uploads in PrestaShop 1.7:

javascriptCopy code
document.addEventListener('DOMContentLoaded', function() {
// Find the file input element for image uploads
var fileInput = document.querySelector('input[type="file"][name="file"]');

// Add "image/svg+xml" to the accepted file types
if (fileInput) {
fileInput.accept += ',image/svg+xml';
}
});

You can add this script to your PrestaShop theme's JavaScript file or directly to a custom JavaScript file that you include in your theme. This script will modify the file input element to accept SVG files by adding "image/svg+xml" to the list of accepted file types.
 

d-shilko

Well-known member
Pro
Master
Diamond
Elite
Joined
Jun 10, 2021
Messages
2,485
Reaction score
1,398
Points
113
NullCash
6,240
Hello, You must read the forum rules.
You have to post it in the OFF-Topic thread.

If you think you post useful information alas it is not!
 
Top