dqvrlgi3247 2017-07-30 20:19
浏览 60
已采纳

PHP表单似乎将操作更改为其他脚本

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>
<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>

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

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

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">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据