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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog