cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.4.1 Import upload fail - The file cannot be uploaded.

SOLVED
Highlighted

Magento 2.4.1 Import upload fail - The file cannot be uploaded.

Hi there,

 

After update M2.4.1, import file cannot upload.

No error message from logs. Directory permission looks ok.

Before upgrade to 2.4.1, upload is no problem.

Screenshot 2020-10-23 at 13.35.12 .jpg

It just throw few words "The file cannot be uploaded.". I have no clue on this.

Thanks for any comments.

 

Regards,

kf

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Magento 2.4.1 Import upload fail - The file cannot be uploaded.

I had the same issue for the last few days, until now...

For me the issue was the new Media Gallery, that was introduced in Magento 2.4.

 

Change this in your backend and hopefully the import will work again:

Stores > Configuration > Advanced > System > Media Gallery > Enable Old Media Gallery: Yes

 

Here is a GitHub link regarding this issue: https://github.com/magento/magento2/issues/30649 

View solution in original post

8 REPLIES 8
Highlighted

Re: Magento 2.4.1 Import upload fail - The file cannot be uploaded.

Screenshot: https://ibb.co/37zY5LW

Highlighted

Re: Magento 2.4.1 Import upload fail - The file cannot be uploaded.

Hi KF,

looking at vendor/magento/framework/File/Uploader.php

there are a number of possible causes:

file does not have extension .zip or .csv (screenshot shows .csv)

file too large? page warns 8MB limit

cannot use/create directory var/importexport for writing file

_FILES not set (see developer tools to make sure request is POST and has you file in the request

 

After that, try stepping through the processing

 

S

 

Highlighted

Re: Magento 2.4.1 Import upload fail - The file cannot be uploaded.

HI @slybandit6791a 

 

Thanks for the suggestion.

 

The file permission should be alright. I tried change to 777 result is the same.

[magento_usr@store-magento File]$ ls -asl
total 56
 0 drwxrws---+  4 magento_usr apache   165 Oct 24 07:15 .
 4 drwxrws---+ 80 magento_usr apache  4096 Oct 21 21:08 ..
 4 -rwxrwx---   1 magento_usr apache  1770 Sep 23 19:59 CsvMulty.php
 4 -rwxrwx---   1 magento_usr apache  3538 Sep 23 19:59 Csv.php
 8 -rwxrwx---   1 magento_usr apache  4247 Sep 23 19:59 Mime.php
 4 -rwxrwx---   1 magento_usr apache   245 Sep 23 19:59 README.md
 4 -rwxrwx---   1 magento_usr apache  3387 Sep 23 19:59 Size.php
 0 drwxrws---+  3 magento_usr apache    18 Oct 21 21:08 Test
 0 drwxrws---+  3 magento_usr apache    21 Oct 21 21:08 Transfer
 4 -rwxrwx---   1 magento_usr apache   793 Sep 23 19:59 UploaderFactory.php
24 -rwxrwx---   1 magento_usr apache 21221 Sep 23 19:59 Uploader.php

 

I double check the source file. It have correct extension ".csv" and I zip the csv file it also not upload.

 

ip12-upload-kf.csv
ip12-upload-kf.zip

File is very very small for test. 1 field only.

 

 

sku,attribute_set_code
KHK-S2F-BK,Protector film

php upload limit is 256M.

 

 

From nginx log command is POST

 

123.123.123.123 - - [24/Oct/2020:07:04:25 +0800] "POST /admin/admin/import/validate/key/12456789356fc7d82a6d086b488f6521d3c96c42db98b8/?form_key=4567894567 HTTP/2.0" 200 295 "https://hostname/admin/admin/import/index/key/13dcaba606bb772901e64c47/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" "-"

 

 

Sorry, I don't know _FILES_ mean. Can you tell me more?

 

I don't have a clue because there is error log found.If it's possible to make it have more meaningful message. It would be great.

 

I will keep trying. If you have more idea, please let me know. 

thank you.

 

Regards,

kf

Highlighted

Re: Magento 2.4.1 Import upload fail - The file cannot be uploaded.

I found the file is in importexport folder but don't know why it doesn't process.

 

[magento_usr@store-magento importexport]$ ls
0Buglqqx3GSqRRtJkBSkNWEXQ1ElIAQT.csv  JYRefr9SVv8IvhumwZSUzzEAaEaFhS6r.csv
1xmw135dJ00pS7FaJyVyJa5lnbd8QodV.zip  Kn2303AsFf744mejjoN1xYVu5TovoiPH.csv
2nKSsCN0skkneHrRVFe7sfSPBQwAyjhz.csv  kQzphYusBT76JSTUlCv9giEo4zMWOuDP.csv
3XBmaac3ZP8vuS94eiiREkycEigr4cqp.csv  Ky56g0YTIXoSItwNsaXeA6kFk12kZSSJ.csv
4FZS0oKHg2g9XTwafVR2LxraNG4NtAmq.csv  mcVKgsXmMUWJn2TLhrMsuL9E8XZDMAdx.csv
4TodExOY8h3b0PWzJVD9vTrGZ331tFxj.csv  nbnqN8mq4snQSfY7Lw02kLyySgj66pJ6.csv
5WxweGl8eUBrwsTzxfmxx8BG31UJgnCB.csv  pbab8xXL4E4o6SxssFaBtXfnsinG4AsI.csv
8W4zkleYHHuvHZHFUVIaHoPRupHLq4GF.csv  RU5AK7TPnV4X6x1DTk5aN7IXyLucRYDs.csv
9PhQTqAIizdR0GXojW9L4Ryu7bJZESA8.csv  uBFAvxJSVTtvFTQkdJZMgcIkEhP7TirW.csv
b18F79RuEpFS7wXQnYD73ULRnjbuf9PB.csv  uKLxQXYlJsvF9Fo77O0r6EyH4Ciyaond.csv
bfHuegBuKyNO68ij75qO4IhcBsY8A8SQ.csv  UodCvK4RqKHgIckmENuSmKWAnJ7MaO8Q.csv
catalog_product.csv                   uRIvx654GsHr81otGWTmTCRsV4R0AU4D.csv
Dszw3X7zwaIUr9INQpDywI2O7xGWJVM5.csv  vBlTlIxKeX0M3vaOeIc5nxnkJcPd5RUR.csv
dtcC2AQpJhZMNOr8DI2i0c0ckOSeWs3f.csv  WOUi8xyWSiCWI6RE8idsYyiRzUSKAdAK.zip
JNCmGxG2XBN5Gf6vbnXsWReS3mLauBtX.csv
Highlighted

Re: Magento 2.4.1 Import upload fail - The file cannot be uploaded.

Hi KF,

 

well the good news is that the file is getting on the server.

 

I would suggest putting some debugging in vendor/magento/module-import-export/Model/Import.php 

within the uploadSource function

try {
            $result = $uploader->save($this->getWorkingDir(), $fileName);
        } catch (\Exception $e) {
print_r($e);
die;
            throw new LocalizedException(__('The file cannot be uploaded.'));
        }

and see what the actual exception is

 

Highlighted

Re: Magento 2.4.1 Import upload fail - The file cannot be uploaded.

I had the same issue for the last few days, until now...

For me the issue was the new Media Gallery, that was introduced in Magento 2.4.

 

Change this in your backend and hopefully the import will work again:

Stores > Configuration > Advanced > System > Media Gallery > Enable Old Media Gallery: Yes

 

Here is a GitHub link regarding this issue: https://github.com/magento/magento2/issues/30649 

View solution in original post

Highlighted

Re: Magento 2.4.1 Import upload fail - The file cannot be uploaded.

Hi @PeterBrain ,

 

I thought I was replied yesterday. You hit the point. 

If you won't tell me I think I will need a decade to find the solution.

Thanks a lot.

 

Regards,

kf

Highlighted

Re: Magento 2.4.1 Import upload fail - The file cannot be uploaded.

Hi @slybandit6791a ,

 

Thanks for reply, finally it's a "New Media Gallery" option cause the problem.

Thanks for your comment, it help me a lot too. Smiley Happy

 

Regards,

kf