"Cannot read import file" problem + solution

"Cannot read import file" problem + solution

by Anna Vanova -
Number of replies: 0
Hi,
I've ran into a problem while importing test questions from a file on our new linux server with this message:

"Cannot read import file (or file is empty)" followed by
"An error occurred during import processing ".

So I turned the debugging on and got more:

Warning: is_readable() [function.is-readable]: open_basedir restriction in effect. File(/var/www/localhost/htdocs/tmp/phpFx...) is not within the allowed path(s): (/var/www/moodedirroot) in /var/www/moodedirroot/question/format.php on line 303

First thing I do in such situations is moodle the solution (which is like google it but better). I didn't find any exact solution (that's why i write this actually) although I found some hints. The real problem and following solution was as simple as this:

In our apache setting (httpd.conf file) is an alias for each web application. In the alias for moodle there was a redefinition for open_basedir php directive but no redefinition for upload_tmp_dir. It's default value is /var/www/localhost/htdocs/tmp/ which works fine for the localhost web apps. So I had to redefine the upload_tmp_dir directive to somewhere under /moodledirroot. You cen see the final piece of httpd.conf code here:

<Location /moodledirroot>
...
php_admin_value open_basedir "/var/www/moodledirroot"
php_admin_value upload_tmp_dir "/var/www/moodledirroot/data/temp"
...
</Location>

Note: I believe, this configuration mistake could have popped up somewhere else too and it has in the end nothing to do with quiz. Uploading files into courses worked fine though.
Average of ratings: Useful (1)