2

I am trying to load data from txt file (| separated) using simple php form. Bellow is the code :

$sql = "LOAD DATA INFILE '".$_FILES['file']['tmp_name']."'
INTO TABLE asn_data
FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\r\n'
IGNORE 2 LINES
";

But when I browse the file and submit it shows following error:

File '/tmp/phpkR9fXW' not found (Errcode: 13)

If I change the syntax to LOAD DATA LOCAL INFILE it provides following error: The used command is not allowed with this MySQL version

My PHP version is 5.3.10, MySQL Version 5.5 and OS is Ubuntu 12.04.1 LTS.

I have tried solution given in http://ubuntuforums.org/showthread.php?t=822084 but no luck.

Layke
  • 51,422
  • 11
  • 85
  • 111
  • Could be related, sice we are talking about ubuntu: http://stackoverflow.com/questions/2783313/how-can-i-get-around-mysql-errcode-13-with-select-into-outfile – complex857 Oct 25 '12 at 19:33
  • Have you tried adding the `LOCAL` keyword into `LOAD DATA INFILE` http://stackoverflow.com/questions/8471727/load-data-infile-does-not-work (also mentioned in the linked thread)? – complex857 Oct 25 '12 at 19:39

1 Answers1

0

We had a very similar problem and it turned out to be a permissions issue where the MySQL server couldn't open the file.

The MySQL Doc's has some useful information on the issue.

Ian Cant
  • 403
  • 3
  • 11