Problem with uploading

Problem with uploading

by Ivan Asenov -
Number of replies: 3

Hi,I don't know if this is the place for this, so i'm sorry if it isn't. I have problem with Moodle 2.6. It's running on windows server 2012. The problem is with uploading files that have cyrillic title. The content inside doesn't matter. If file titles are in english, everything is ok, but if they are in cyrillic, they upload, but when you try to open them it shows this error:

Debug info:
Error code: filenotfound
Stack trace:
  • line 463 of \lib\setuplib.php: moodle_exception thrown
  • line 1948 of \lib\filelib.php: call to print_error()
  • line 4572 of \lib\filelib.php: call to send_file_not_found()
  • line 37 of \pluginfile.php: call to file_pluginfile()

Does anyone have suggestions? I think it's from the server, but i'm not sure.

Average of ratings: -
In reply to Ivan Asenov

Re: Problem with uploading

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Ivan,

This may not help much, but when I do a search for "file names cyrillic" in Google, it returns 946,000 results. Obviously this is a much wider problem than with using Moodle itself.

Joseph

In reply to Joseph Rézeau

Re: Problem with uploading

by Лина Йорданова -

I would like to add something to this question. When we used prewios Moodle versions we did not have any problems with having our file in cyrrilic. The system coverted their names into latin.  How this could be?

Lina

In reply to Лина Йорданова

Re: Problem with uploading

by Chris Fryer -

This is likely to be an artefact of Moodle 2.x's file system.  It is completely unlike the Moodle 1.x system.  Details are here:

http://docs.moodle.org/dev/File_API_internals

Files you upload to Moodle are named, on disk, as the SHA1 digest of their contents.  This digest is stored in Moodle's database together with the name you gave the file.  So when you request a Moodle file, you are asking the database to look up the SHA1 digest associated with the name you gave the file, and then to find a file on the disk whose name matches that digest.  (Phew!)

However, I cannot reproduce the problem Ivan describes.  I uploaded a file called "Русский" to my test installation of Moodle, and can download it fine.

What database are you using?  If it is MySQL, you should check the character set and collation of the database as follows:

mysql> show create database moodle;
+----------+-----------------------------------------------------------------------------------------+
| Database | Create Database |
+----------+-----------------------------------------------------------------------------------------+
| moodle | CREATE DATABASE `moodle` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */ |
+----------+-----------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Note that the character set is utf8 and the collation is utf8_unicode_ci;

mysql> SELECT `table_collation` FROM `information_schema`.`tables` WHERE `table_schema` = 'moodle' AND `table_name` = 'mdl_files';

You should get one row:

+-----------------+
| table_collation |
+-----------------+
| utf8_unicode_ci |
+-----------------+
1 row in set (0.00 sec)

Next, check the collation of the columns in the table.

mysql> SHOW FULL COLUMNS FROM `moodle`.`mdl_files`;

Look at the "Collation" column.  You should see NULL for any BIGINT columns, and utf8_unicode_ci for the VARCHAR and LONGTEXT columns.

If everything is as expected, you need to check the collation of the connection from your web server to your database.  You can do this by creating a file in your Moodle webserver's root with the following contents:

<?php
echo '<pre>';
include_once('config.php');
print_r($DB->get_records_sql("show local variables like 'character_set_connection'"));
print_r($DB->get_records_sql("show local variables like 'collation_connection'"));

This should give you a page that looks like this:

Array
(
    [character_set_connection] => stdClass Object
        (
            [variable_name] => character_set_connection
            [value] => utf8
        )

)
Array
(
    [collation_connection] => stdClass Object
        (
            [variable_name] => collation_connection
            [value] => utf8_general_ci
        )

)

Although there are a number of utf8-compatible collations you could use, I am not sure Moodle is 100% compatible with them all.

I'd be interested to know your results.

Chris