Whenever I try to upload a file to import into phpMyAdmin I get the following error:

File could not be read

phpMyAdmin is the only php script I am running on my server, and as such my php configuration file is fairly vanilla except for the following changes:

upload_tmp_dir = /tmp
upload_max_filesize = 10M
post_max_size = 50M
memory_limit = 64M

The file I am trying to import is 4MB, well within the 10MB upload size and 50MB post size (it is also UTF-8). Setting upload_tmp_dir actually fixed a previous problem I was having (where phpMyAdmin was complaining that I didn't even specify a file) or at least made the error change to what I am getting now. The permissions on /tmp are 777.

What could the problem be? The file comes from a cpanel installation at hostmonster I am migrating away from onto my own vps. I have tried getting the sql file from the cpanel backup utility and from their installation of phpMyAdmin (both uncompressed and gzipped). I do not believe that the files are corrupted.

Extra information: I am running CentOS 5.6, phpMyAdmin 3.4.2, mysql 5.1.52, and php 5.2.16.

  • Are the web server error logs showing anything that could give you more of a clue as to what is going on? – Bart B Jun 10 '11 at 12:59
  • Just to make sure I set the log to a new file and tried the upload. The only entries in the new file pertain to my self signed ssl certificate. The SSL is actually something I added in after I was already getting this error. – knpwrs Jun 10 '11 at 13:22

If open_basedir is set in your php.ini PHP will not be able access files above that directory.

  • Aha! I had open_basedir set to /var/www/vhosts. I changed it to /var/www and set up a temp directory there. – knpwrs Jun 10 '11 at 17:30

I think the problem is setting of php.ini:

upload_tmp_dir = /tmp
open_basedir = /data/home/:/tmp/

The open_basedir needs add the /tmp/ too


I think you can setup this in the configuration file php.ini:

upload_tmp_dir = /tmp
open_basedir = /var/www:/data/home:/tmp

But, don't add the last slash of the targeted directories. Founded in the php documentation :

When you want to restrict access to only the specified directory, end with a slash. For example: open_basedir = /dir/incl/


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.