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
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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.