Jump to content

Uploading XML into MySQL database using PHP


Nazirul

Recommended Posts

Hello all

 

i want to upload an XML file into MySQL

 

this is the form example  ;D

 

<form method="post" enctype="multipart/form-data">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="xmlfile" type="file" id="xmlfile">
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>

 

it looks like : uploadrtr.jpg

 

in MySQL 6.0, we can load xml file into mysql using this code :

 

LOAD XML LOCAL INFILE 'student.xml' INTO TABLE student_information ROWS IDENTIFIED BY '<student_information>';

 

so my question is, how do we upload the file and at the same time run the LOAD XML code... help me to figure it out.

 

thanks..  ;)

You need to supply an actual file to the LOAD XML LOCAL INFILE ... query, which means your upload form processing code would either need to use the upoladed $_FILES['xmlfile']['tmp_name'] name (assuming that permissions will allow the mysql client library access to it) or if that does not work you would need to move/copy the uploaded file to a regular file with the correct permissions so that the mysql client can access it for the query.

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.