Error: The uploaded file is not a csv

[ad_1]

Hi jujhar330,
as the feature states – I can only offer limited support for the importer because the vast majority of issues a user will have with it are out of my control. But I’ll do my best!

So first off – this is very weird and something I’ve never come across before.

I am able to upload those files which contain 2 or less lines

I have no real idea what could cause something like that :S

I have a solution for you that you can skip to the end of this if you want to get right into it. Keep reading if you want to go down the rabbit hole.

The way file uploads work is that when a file is uploaded to a server, it is first placed in a sort of limited sandbox area before being moved to the “real” place on your server. This is done mainly for security so that we can do things like verify that the file is what it claims to be before moving to a location where a malicious file could potentially do harm.

In this sandbox area, HD Quiz does several things to verify the integrity of the file before risking using the file to import quizzes.

One thing we do is check the file’s mimetype. A CSV should always have a mimetype of either text/plain or text/csv. If the file you uploaded has a different mimetype, then we return the message “Uploaded file was not a CSV”.

The other thing we do is check the file’s extension. For example, does the filename end in .txt, .php, .exe, .zip etc. A CSV file should obviously end in .csv. So if the extension is not .csv we return the “Uploaded file was not a CSV” message.

The above are the only two ways that HD Quiz will return the “Not a CSV” message. The problem here is that you said this also happens with the demo file – which absolutely has the text/csv mimetype and absolutely has the .csv extension.

So what is going on?

It seems that your server either
A) is unable to determine file extensions, or
B) is unable to determine mimetypes.

But if that were the case, then why does it work if you use a file that has two or less lines? The only idea I have is that your host is using up all of its storage in the /tmp/ folder (the sandboxed folder I mentioned above). Most shared hosts share this folder across multiple accounts. Are you able to upload multiple images to the WordPress media library without issue? Other than that, I’m stumped. HOWEVER

Solution

If you are still able to upload files using the WordPress media library, upload your CSV file there and copy the URL.

You will now need to do a small edit to HD Quiz. What we will do is still use the “upload” as a trigger to start everything, but instead of trying to use the current file, we will instead use the file you added using the media library.

If you edit ./hd-quiz/includes/tools/csv_import.php on line 123 you will see $csvFile = "";. Above that line, add the following code.

$csvFile = "URL TO THE CSV FILE";
hdq_parse_csv_data($csvFile, $hdq_nonce);
return "uploading";

Replace “URL TO THE CSV FILE” with… the URL of the CSV you uploaded using the WordPress media library.

If all works, this should allow the import to work as usual.

If you are unable to upload any files, even using the media library, then this is something you will need to contact your host about.

Sorry about this super long response, but hopeful you or someone else will find it useful (and please let me know if you get this working)!

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer