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

Link to comment
Share on other sites

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.

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.