一直在网上磕磕绊绊,很难找到获取浏览文件的文件路径的示例。其中一些我读到由于安全原因,此功能不再起作用。有什么想法吗?我非常需要一个样品。我已经试过很多次了。
这是目前我有:
<html>
<body>
<form method="post" action="file.php" enctype="multipart/form-data">
<input type="radio" name="type" value="moodle" required="required" /> Moodle<br />
<input type="radio" name="type" value="bb" required="required" /> BlackBoard<br />
<input type="file" name="file" id="file" /><br /><br />
<input type="submit" value="Submit" name="submit" />
</form>
</body>
</html>
文件.php
<?php
$filetype = $_POST["type"];
echo $filetype;
echo "Upload: " . $_FILES['file']['name'] . "<br />";
echo "Type: " . $_FILES['file']['tmp_name'];
if ($_FILES['file']['error'] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES['file']['name'] . "<br />";
echo "Type: " . $_FILES['file']['type'] . "<br />";
echo "Size: " . ($_FILES['file']['size'] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES['file']['tmp_name'];
}
function moodlezip($zipfile){
echo "<h1>MOODLE</h1>"."<br />";
$moodle = new Moodle();
$zip = zip_open($zipfile);
$ziparc = new ZipArchive;
if ($zip)
{
while ($zip_entry = zip_read($zip))
{
$file = zip_entry_name($zip_entry);
//echo "Name: " . $file . "<br />";
if (strpos($file,'course.xml') !== false) {
if ($ziparc->open($zipfile) === TRUE) {
$coursexml = new SimpleXMLElement($ziparc->getFromName($file));
$moodle->getCourse($coursexml);
$ziparc->close();
} else {
echo 'failed';
}
}
else if (strpos($file,'forum.xml') !== false) {
if ($ziparc->open($zipfile) === TRUE) {
$topicxml = new SimpleXMLElement($ziparc->getFromName($file));
$moodle->getTopic($topicxml);
$ziparc->close();
} else {
echo 'failed';
}
}
else if (strpos($file,'lesson.xml') !== false) {
if ($ziparc->open($zipfile) === TRUE) {
$lessonxml = new SimpleXMLElement($ziparc->getFromName($file));
$moodle->getLessons($lessonxml);
$ziparc->close();
} else {
echo 'failed';
}
}
else if (strpos($file,'quiz.xml') !== false) {
if ($ziparc->open($zipfile) === TRUE) {
$quizxml = new SimpleXMLElement($ziparc->getFromName($file));
$moodle->getQuizzes($quizxml);
$ziparc->close();
} else {
echo 'failed';
}
}
else if (strpos($file,'questions.xml') !== false) {
if ($ziparc->open($zipfile) === TRUE) {
$questionsxml = new SimpleXMLElement($ziparc->getFromName($file));
$moodle->getQuestions($questionsxml);
$ziparc->close();
} else {
echo 'failed';
}
}
}
zip_close($zip);
}
}
require_once 'classes/backup.php';
$connect = mysql_connect("localhost","root","");
if (!$connect)
{
die('Could not connect: ' . mysql_error());
}
mysql_close($connect);
//form upload loop folders input submit, find, bb, scorm
//class admin
?>