这是在我的 html/php 文件中...我只是将其设置为提交给自己,因为这对我来说很容易。
<?php
if (isset($_FILES['file'])) {
$file = $_FILES['file']['tmp_name'];
$catalog = simplexml_load_file($file);
echo '<table style="border-spacing: 10px;">';
echo '<tr><th>Title</th><th>Author</th></tr>';
foreach ($catalog->book as $b) {
echo '<tr><td>'.$b->title.'</td><td>'.$b->author.'</td></tr>';
}
echo '</table>';
}
else {
?>
<!-- change the filename below -->
<form action="filename.html" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php } ?>
这是我在文件中使用的xml,用于与表单一起上传...
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
<book id="bk103">
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
<description>After the collapse of a nanotechnology
society in England, the young survivors lay the
foundation for a new society.</description>
</book>
</catalog>
它只是显示上传表单或图书目录
Title Author
XML Developer's Guide Gambardella, Matthew
Midnight Rain Ralls, Kim
Maeve Ascendant Corets, Eva
也...如下链接所述...如果您不移动或重命名临时文件,它将在 php 脚本结束时被删除。
php:: how long to tmp files stay?