Search code examples
phpmysqlfilecodeigniterload-data-infile

how to import data to the mysql database from a text file located in the server


i am successful to import data from my local pc but the problem is,it is not working on the server here is the code that works fine when i load the file from pc directory

LOAD DATA LOCAL INFILE 'C:/test.txt' INTO TABLE pet fields terminated by ',';

but it doesn't work when i put server location like

LOAD DATA LOCAL INFILE 'http://localhost/farzana/erp_fiat/files/test.text' INTO TABLE pet fields terminated by ',';

it will be very helpful if someone fix this problem


Solution

  • replace test.text with test.txt in the url and paste the URL in the browser if you can see the file,

    else use the absolute path of the directory, instead of the URL