Jump to content

Running "LOAD DATA INFILE" with PHP


asongisabeautifullie

Recommended Posts

As part of an administrator\'s page for a site I want to include an option to upload a text file for bulk loading into the database.

 

I was thinking that I could do this with a form, where the POSTed file would have name=\"bulk\". The path to the uploaded file will then be $bulk.

 

I would then run an sql query loading data from this file into the table.

 

So far I\'ve failed miserably at making this happen, if anyone has any clever ideas please post your script suggestions.

 

Cheers!

Link to comment
https://forums.phpfreaks.com/topic/318-running-load-data-infile-with-php/
Share on other sites

The main problem with what I\'ve tried so far is that LOAD DATA INFILE will only open a file in the database\'s data folder in the mysql folder.

 

I tested to see where the uploaded file goes, and it was something like C:PHPuploadtempphp8.tmp

 

While I\'m doing this on my own local server I know I could use this code to move the file to the database directory:

 

if (is_uploaded_file($bulk)) {

move_uploaded_file($bulk, \"C:MySQLdatabooksbulk.txt\");

}

 

But I can\'t do this on my web host cos I wouldn\'t have permission...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.