Jump to content


Photo

Running "LOAD DATA INFILE" with PHP


  • Please log in to reply
2 replies to this topic

#1 asongisabeautifullie

asongisabeautifullie
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationLondon

Posted 06 April 2003 - 11:19 PM

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!
Calm down it\'s all a dream...
[br]*CEPHAS* | crimebooks.co.uk

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 07 April 2003 - 04:54 AM

sounds like an ok idea. what part is the script failing on?
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 asongisabeautifullie

asongisabeautifullie
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationLondon

Posted 07 April 2003 - 11:24 AM

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...
Calm down it\'s all a dream...
[br]*CEPHAS* | crimebooks.co.uk




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users