File upload Error 2 (Import CSV to Dataset)

Got “The file exceeds the maximum allowed file size. [Code 2]”, while attempting to import CSV, despite my PHP.ini being set correctly, even according to this topic.

I’ve even tried uploading a zero-byte file, though that ended up with Code 4.

I’m on Version 1.7.9.

I was clued in on this comment on StackOverflow:

I’m also facing this error and I’ve noticed it’s because the maximum file size specified in “value” should be a power of 2. In particular, I was setting value=“500000” and I’ve turned it to value=“524288”

Apparently something wrong with converting 2G to whatever number PHP likes in the upload form?

In the Media Uploader (which works) this field is: 2147483648, but isn’t included as MAX_FILE_SIZE. :confused:

The issue is only regarding dataset imports? All other uploads (images, videos) are working fine?

Could you double check all php.ini settings (and any notes regarding your environment if applicable? - How do I upload files bigger than 2MB / How can I increase the upload file size limit?

Do you have any special characters in data set name, columns etc?

so for this topic, yes the issue is only with the file upload part.

All other uploads seem to work fine, php.ini is all good, this really shouldn’t be happening.

Could you perhaps send me the .csv file via private message so I can try it in our environment?

Alternatively you could order demo cms instance hosted with spring signage and try to recreate the issue there - that should help us to know where the problem could be.

Ah… file upload types are limited in this install of Discourse.

Have a paste!

This file does suffer a bit from MS Excel adding SmartQuotes and other such characters, but the issue occurs before the actual import, so I figure it’s fine.

Side note: This file (even with special characters removed) will fail to import, because for some reason the value column in the database is set to 255 characters, and there are quite a few description cells that are much longer than that (almost double even).

1.7.9 does have that limit to 255 characters in a field - 1.8 does not have this problem anymore.

Other than that I imported your csv without any issues - the descriptions are cut if they were longer than 255 characters, but that’s only issue I had.

Could you double check everything in php.ini (and notes for specific environment if applicable) How do I upload files bigger than 2MB / How can I increase the upload file size limit?

Yeah, everything seems fine as indicated by the non-problem with the media upload section.

My settings are as follows:

php.ini:

post_max_size = 2G
upload_max_filesize = 2G

nginx.conf:

        client_max_body_size 2G;

I’m pretty sure it’s just a glitch in how PHP is interpreting the form parameter MAX_FILE_SIZE that appears only in the CSV importer and not in the media upload tool, as the moment I modify the DOM to eliminate it from the submission, it works. It’s possible it works in other situations because the calculations for 500M or 20M or whatever do correctly expand out to whatever PHP is expecting, but 2G does not.

I believe we’ve encountered some issue when the limits were set to 2G (or more), you could try to go with 1999M that’s what we have in our cloud hosting settings as well as I believe in docker.

1 Like

Hi guys
Cant upload more than 7 m i changed setting to 2G but its says below

SyntaxError: Unexpected token < in JSON at position 0