Jump to content
Updating IPB tonight Read more... ×

Archived

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

asongisabeautifullie

Running "LOAD DATA INFILE" with PHP

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!

Share this post


Link to post
Share on other sites

sounds like an ok idea. what part is the script failing on?

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

×

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.