MySQL Forums
Forum List  »  PHP

How insert data in table using a .txt file
Posted by: Julia Fleur
Date: April 05, 2010 10:41AM

How do you do this if you are uploading the .txt file in a form like this:

index.php:

<form method="post" action="process_upload.php" enctype="multipart/form-data">
<input type="file" name="filename" value="Locate File" /><br /><br />
<input type="submit" value="Submit File" />
</form>

TO

process_upload.php:

<?php

$result = MYSQL_QUERY("LOAD DATA LOCAL INFILE '$filename' INTO TABLE data LINES TERMINATED BY '\r\n'");

echo "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">";
mysql_close();


?>

^----- is not working for me, i think there's a problem with $filename part, what do I do so that it grabs the file i uploaded using the form?



Edited 1 time(s). Last edit at 04/05/2010 10:43AM by Julia Fleur.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.