2017-07-30 20:19
浏览 60


I'm building a website that has a form that allows users to upload files, but the form seems to be going to the wrong place. I told it to go to "upload.php", but instead it tries to go to "“upload.php", which I did not include in the form action. It doesn't look like I added any unicode characters in the script. Any reason why this might be happening?

Here's my form in index.html: https://pastebin.com/7PETk5Sy

<!DOCTYPE html>
  <link type="text/css" rel="stylesheet" href="style.css"/>
  <div id="titlebar">
  <img src="DeeperNetIcon.jpg"></img>
  <a href="http://oriondark7.com/deeper">Back to Deeper Homepage</a>
  <form action="view.php" method="post">Search for World by ID: <input type="text" name="world">  <input type="submit" value="Search"></form>
  <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:
    <input type="file" name="world">
    World Name:
    <input type="text" name="name">
    <input type="textbox" name="desc">
    <input type="submit" value="Upload World">


The index.html File has 2 Forms, the second form is the one I'm talking about.

Here's my upload.php Script: https://pastebin.com/0FyuAX3Q

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'] . "
                    fwrite($info, $_POST['desc']);

MAMP says I'm using PHP 7.0.8 if you're wondering.

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doucha4054 2017-07-30 20:21

    Replace your code with this as form accepts this double quotes (") not this one (“)

    <form action="upload.php" method="post" enctype="multipart/form-data">
    解决 无用
    打赏 举报

相关推荐 更多相似问题