我正在構建一個具有允許用戶上載文件的窗體的網站,但窗體似乎要到錯誤的地方。我告訴它去「upload.php」,但它試圖去「上載.php」,我沒有包括在表單動作。它看起來不像我在腳本中添加任何unicode字符。任何可能發生這種情況的原因?PHP窗體似乎將操作更改爲不同的腳本
這裏是我的表格中的index.html: https://pastebin.com/7PETk5Sy
<!DOCTYPE html>
<html>
<head>
<title>Deeper</title>
<link type="text/css" rel="stylesheet" href="style.css"/>
</head>
<body>
<div id="titlebar">
<img src="DeeperNetIcon.jpg"></img>
<h1>DeeperNet</h1>
<a href="http://oriondark7.com/deeper">Back to Deeper Homepage</a>
<br/><br/>
<form action="view.php" method="post">Search for World by ID: <input type="text" name="world"> <input type="submit" value="Search"></form>
<br/>
</div>
<p color="white">Welcome to DeeperNet!</p>
<div id="upload">
<h1>Upload World to DeeperNet</h1>
<form action=「upload.php」 method="post" enctype="multipart/form-data">
World File:
<br/><br/>
<input type="file" name="world">
<br/><br/>
World Name:
<br/>
<input type="text" name="name">
<br/>
Description:
<br/>
<input type="textbox" name="desc">
<br/><br/>
<input type="submit" value="Upload World">
</form>
<br/>
</div>
</body>
index.html文件有2種形式,第二種形式是我在談論的一個。
這裏是我的upload.php程序: https://pastebin.com/0FyuAX3Q
<?php
include("index.html");
if(!empty($_POST)) {
if(isset($_FILES["world"])) {
$world = $_FILES["world"];
$name = $world["name"];
$tmp_name = $world["tmp_name"];
$size = $world["size"];
$ext = explode('.', $name);
$ext = strtolower(end($ext));
$allowed = "deep";
if ($ext == $allowed) {
if ($size <= 300000) {
$id = uniqid('', true);
$destination = 'worlds/' . $id . '.' . $ext;
if(move_uploaded_file($tmp_name, $destination)) {
echo '<br/>World: "' . $name . '" uploaded to DeeperNet!';
echo 「<br/>World ID: 」 . $id;
$info = fopen('worlds/' . $id . '.txt', 'w');
fwrite($info, $_POST['name'] . "\r\n");
fwrite($info, $_POST['desc']);
fclose($info);
}
}
}
MAMP說我使用的是PHP 7.0.8,如果你想知道。
因爲'「'是不是真正的報價。 –
雙引號'」'沒有引號 –
對不起雖然有點偏離主題,但'''實際上比'''更真實__「,但它們對HTML屬性定義無效 – lynx