Validation for file type not working in File Upload in Magento 2 Store ConfigurationCustom system configuration fieldsMagento direct sql query not working in my dynamic adminhtml module configProduct Custom Option “File Upload” not workingMagento model extension experiment, return: “class does not exist”Magento : Admin Form Input Type “file” Value not WorkingMagento 2 custom module configuration settings not display in adminGet upload_dir for custom system configuration file upload || getFieldConfig for custom system configurationMagento 2 Saving store configuration programatically in upgrade scriptmagento2 file upload Pdf not workingMagento 2 :upload file type restrict to pdf only
Are gliders susceptible to bird strikes?
Who voices the character "Finger" in The Fifth Element?
Was it really unprofessional of me to leave without asking for a raise first?
What exactly did Ant-Man see that made him say that their plan worked?
Losing queen and then winning the game
If two black hole event horizons overlap (touch) can they ever separate again?
Sacrifice blocking creature before damage is dealt no longer working (MtG Arena)?
What game is this character in the Pixels movie from?
Is it okay to fade a human face just to create some space to place important content over it?
Could human civilization live 150 years in a nuclear-powered aircraft carrier colony without resorting to mass killing/ cannibalism?
How receiver knows the exact frequency in the channel to "listen to"?
Closest Proximity of Oceans to Freshwater Springs
How did they film the Invisible Man being invisible, in 1933?
What do you call a notepad used to keep a record?
Is there reliable evidence that depleted uranium from the 1999 NATO bombing is causing cancer in Serbia?
Put my student loan in parents’ second mortgage - help?
Does a Hand Crossbow with the Repeating Shot Infusion still require a Free Hand to use?
Converting Geographic Coordinates into Lambert2008 coordinates
Can you actually break an FPGA by programming it wrong?
Company threatening to call my current job after I declined their offer
Reusable spacecraft: why still have fairings detach, instead of open/close?
13th chords on guitar
Why did NASA wet the road in front of the Space Shuttle crawler?
Comment traduire « That screams X »
Validation for file type not working in File Upload in Magento 2 Store Configuration
Custom system configuration fieldsMagento direct sql query not working in my dynamic adminhtml module configProduct Custom Option “File Upload” not workingMagento model extension experiment, return: “class does not exist”Magento : Admin Form Input Type “file” Value not WorkingMagento 2 custom module configuration settings not display in adminGet upload_dir for custom system configuration file upload || getFieldConfig for custom system configurationMagento 2 Saving store configuration programatically in upgrade scriptmagento2 file upload Pdf not workingMagento 2 :upload file type restrict to pdf only
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am following below Article to upload file in store configuration:
https://www.mageplaza.com/devdocs/how-file-upload-sytem-configuration-magento-2.html
I have defined custom backend model as mentioned in this artice to validate my file type:
<?php
namespace VendorPackageModelConfigBackend;
class CustomFileType extends MagentoConfigModelConfigBackendFile
/**
* @return string[]
*/
public function getAllowedExtensions()
return ['csv'];
?>
and in system.xml, it's like this:
<field id="import" translate="label" type="MagentoConfigBlockSystemConfigFormFieldFile" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Import CSV</label>
<comment>Comment</comment>
<backend_model>VendorPackageModelConfigBackendCustomFileType</backend_model>
<upload_dir>upload</upload_dir>
</field>
but it's not working. I can upload image files too!!
What's wrong with this code?
magento2 configuration file-upload custom-validation
add a comment |
I am following below Article to upload file in store configuration:
https://www.mageplaza.com/devdocs/how-file-upload-sytem-configuration-magento-2.html
I have defined custom backend model as mentioned in this artice to validate my file type:
<?php
namespace VendorPackageModelConfigBackend;
class CustomFileType extends MagentoConfigModelConfigBackendFile
/**
* @return string[]
*/
public function getAllowedExtensions()
return ['csv'];
?>
and in system.xml, it's like this:
<field id="import" translate="label" type="MagentoConfigBlockSystemConfigFormFieldFile" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Import CSV</label>
<comment>Comment</comment>
<backend_model>VendorPackageModelConfigBackendCustomFileType</backend_model>
<upload_dir>upload</upload_dir>
</field>
but it's not working. I can upload image files too!!
What's wrong with this code?
magento2 configuration file-upload custom-validation
Code looks fine. Did you run di:compile and flushed the cache as well?
– Sukumar Gorai
Jun 20 at 11:47
yes. I flushed the cache. do i need to run di:compile in developer mode too?
– Khushbu
Jun 20 at 11:50
Yes run once because if not compiled then might be an issue.
– Sukumar Gorai
Jun 20 at 11:56
Thank you @SukumarGorai. But i got the solution. See my answer.
– Khushbu
Jun 20 at 11:57
Yes I have checked. Happy coding!
– Sukumar Gorai
Jun 20 at 11:58
add a comment |
I am following below Article to upload file in store configuration:
https://www.mageplaza.com/devdocs/how-file-upload-sytem-configuration-magento-2.html
I have defined custom backend model as mentioned in this artice to validate my file type:
<?php
namespace VendorPackageModelConfigBackend;
class CustomFileType extends MagentoConfigModelConfigBackendFile
/**
* @return string[]
*/
public function getAllowedExtensions()
return ['csv'];
?>
and in system.xml, it's like this:
<field id="import" translate="label" type="MagentoConfigBlockSystemConfigFormFieldFile" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Import CSV</label>
<comment>Comment</comment>
<backend_model>VendorPackageModelConfigBackendCustomFileType</backend_model>
<upload_dir>upload</upload_dir>
</field>
but it's not working. I can upload image files too!!
What's wrong with this code?
magento2 configuration file-upload custom-validation
I am following below Article to upload file in store configuration:
https://www.mageplaza.com/devdocs/how-file-upload-sytem-configuration-magento-2.html
I have defined custom backend model as mentioned in this artice to validate my file type:
<?php
namespace VendorPackageModelConfigBackend;
class CustomFileType extends MagentoConfigModelConfigBackendFile
/**
* @return string[]
*/
public function getAllowedExtensions()
return ['csv'];
?>
and in system.xml, it's like this:
<field id="import" translate="label" type="MagentoConfigBlockSystemConfigFormFieldFile" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Import CSV</label>
<comment>Comment</comment>
<backend_model>VendorPackageModelConfigBackendCustomFileType</backend_model>
<upload_dir>upload</upload_dir>
</field>
but it's not working. I can upload image files too!!
What's wrong with this code?
magento2 configuration file-upload custom-validation
magento2 configuration file-upload custom-validation
asked Jun 20 at 11:29
KhushbuKhushbu
30713 bronze badges
30713 bronze badges
Code looks fine. Did you run di:compile and flushed the cache as well?
– Sukumar Gorai
Jun 20 at 11:47
yes. I flushed the cache. do i need to run di:compile in developer mode too?
– Khushbu
Jun 20 at 11:50
Yes run once because if not compiled then might be an issue.
– Sukumar Gorai
Jun 20 at 11:56
Thank you @SukumarGorai. But i got the solution. See my answer.
– Khushbu
Jun 20 at 11:57
Yes I have checked. Happy coding!
– Sukumar Gorai
Jun 20 at 11:58
add a comment |
Code looks fine. Did you run di:compile and flushed the cache as well?
– Sukumar Gorai
Jun 20 at 11:47
yes. I flushed the cache. do i need to run di:compile in developer mode too?
– Khushbu
Jun 20 at 11:50
Yes run once because if not compiled then might be an issue.
– Sukumar Gorai
Jun 20 at 11:56
Thank you @SukumarGorai. But i got the solution. See my answer.
– Khushbu
Jun 20 at 11:57
Yes I have checked. Happy coding!
– Sukumar Gorai
Jun 20 at 11:58
Code looks fine. Did you run di:compile and flushed the cache as well?
– Sukumar Gorai
Jun 20 at 11:47
Code looks fine. Did you run di:compile and flushed the cache as well?
– Sukumar Gorai
Jun 20 at 11:47
yes. I flushed the cache. do i need to run di:compile in developer mode too?
– Khushbu
Jun 20 at 11:50
yes. I flushed the cache. do i need to run di:compile in developer mode too?
– Khushbu
Jun 20 at 11:50
Yes run once because if not compiled then might be an issue.
– Sukumar Gorai
Jun 20 at 11:56
Yes run once because if not compiled then might be an issue.
– Sukumar Gorai
Jun 20 at 11:56
Thank you @SukumarGorai. But i got the solution. See my answer.
– Khushbu
Jun 20 at 11:57
Thank you @SukumarGorai. But i got the solution. See my answer.
– Khushbu
Jun 20 at 11:57
Yes I have checked. Happy coding!
– Sukumar Gorai
Jun 20 at 11:58
Yes I have checked. Happy coding!
– Sukumar Gorai
Jun 20 at 11:58
add a comment |
2 Answers
2
active
oldest
votes
I found answer by referring
vendormagentomodule-configModelConfigBackendFile.php
Correct Function name is _getAllowedExtensions not getAllowedExtensions
So, correct method is:
public function _getAllowedExtensions()
return ['csv'];
its not necessary
– Rk Rathod
Jun 20 at 12:17
You can try this code!
– Khushbu
Jun 20 at 12:25
i'm also try this
– Rk Rathod
Jun 20 at 12:27
add a comment |
Replace backend_model with this :-
<backend_model>MagentoConfigModelConfigBackendFile</backend_model>
this is not working!
– Khushbu
Jun 20 at 11:49
i think your controller is not called
– Rk Rathod
Jun 20 at 11:51
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f279022%2fvalidation-for-file-type-not-working-in-file-upload-in-magento-2-store-configura%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I found answer by referring
vendormagentomodule-configModelConfigBackendFile.php
Correct Function name is _getAllowedExtensions not getAllowedExtensions
So, correct method is:
public function _getAllowedExtensions()
return ['csv'];
its not necessary
– Rk Rathod
Jun 20 at 12:17
You can try this code!
– Khushbu
Jun 20 at 12:25
i'm also try this
– Rk Rathod
Jun 20 at 12:27
add a comment |
I found answer by referring
vendormagentomodule-configModelConfigBackendFile.php
Correct Function name is _getAllowedExtensions not getAllowedExtensions
So, correct method is:
public function _getAllowedExtensions()
return ['csv'];
its not necessary
– Rk Rathod
Jun 20 at 12:17
You can try this code!
– Khushbu
Jun 20 at 12:25
i'm also try this
– Rk Rathod
Jun 20 at 12:27
add a comment |
I found answer by referring
vendormagentomodule-configModelConfigBackendFile.php
Correct Function name is _getAllowedExtensions not getAllowedExtensions
So, correct method is:
public function _getAllowedExtensions()
return ['csv'];
I found answer by referring
vendormagentomodule-configModelConfigBackendFile.php
Correct Function name is _getAllowedExtensions not getAllowedExtensions
So, correct method is:
public function _getAllowedExtensions()
return ['csv'];
answered Jun 20 at 11:55
KhushbuKhushbu
30713 bronze badges
30713 bronze badges
its not necessary
– Rk Rathod
Jun 20 at 12:17
You can try this code!
– Khushbu
Jun 20 at 12:25
i'm also try this
– Rk Rathod
Jun 20 at 12:27
add a comment |
its not necessary
– Rk Rathod
Jun 20 at 12:17
You can try this code!
– Khushbu
Jun 20 at 12:25
i'm also try this
– Rk Rathod
Jun 20 at 12:27
its not necessary
– Rk Rathod
Jun 20 at 12:17
its not necessary
– Rk Rathod
Jun 20 at 12:17
You can try this code!
– Khushbu
Jun 20 at 12:25
You can try this code!
– Khushbu
Jun 20 at 12:25
i'm also try this
– Rk Rathod
Jun 20 at 12:27
i'm also try this
– Rk Rathod
Jun 20 at 12:27
add a comment |
Replace backend_model with this :-
<backend_model>MagentoConfigModelConfigBackendFile</backend_model>
this is not working!
– Khushbu
Jun 20 at 11:49
i think your controller is not called
– Rk Rathod
Jun 20 at 11:51
add a comment |
Replace backend_model with this :-
<backend_model>MagentoConfigModelConfigBackendFile</backend_model>
this is not working!
– Khushbu
Jun 20 at 11:49
i think your controller is not called
– Rk Rathod
Jun 20 at 11:51
add a comment |
Replace backend_model with this :-
<backend_model>MagentoConfigModelConfigBackendFile</backend_model>
Replace backend_model with this :-
<backend_model>MagentoConfigModelConfigBackendFile</backend_model>
answered Jun 20 at 11:39
Rk RathodRk Rathod
2,4233 silver badges18 bronze badges
2,4233 silver badges18 bronze badges
this is not working!
– Khushbu
Jun 20 at 11:49
i think your controller is not called
– Rk Rathod
Jun 20 at 11:51
add a comment |
this is not working!
– Khushbu
Jun 20 at 11:49
i think your controller is not called
– Rk Rathod
Jun 20 at 11:51
this is not working!
– Khushbu
Jun 20 at 11:49
this is not working!
– Khushbu
Jun 20 at 11:49
i think your controller is not called
– Rk Rathod
Jun 20 at 11:51
i think your controller is not called
– Rk Rathod
Jun 20 at 11:51
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f279022%2fvalidation-for-file-type-not-working-in-file-upload-in-magento-2-store-configura%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Code looks fine. Did you run di:compile and flushed the cache as well?
– Sukumar Gorai
Jun 20 at 11:47
yes. I flushed the cache. do i need to run di:compile in developer mode too?
– Khushbu
Jun 20 at 11:50
Yes run once because if not compiled then might be an issue.
– Sukumar Gorai
Jun 20 at 11:56
Thank you @SukumarGorai. But i got the solution. See my answer.
– Khushbu
Jun 20 at 11:57
Yes I have checked. Happy coding!
– Sukumar Gorai
Jun 20 at 11:58