繁体   English   中英

它不会通过变量吗? 文件PHP

[英]It won't pass through the variable? FILES php

我正在尝试上传图片...

我还有很多表单元素,但我认为这是唯一重要的部分

<form name="register" method="post" action="profiles.php" onSubmit="return validateForm()">

        <td class="col1">Profile Picture</td>
         <td class="col2">
            <input type="file" name="file" id="file">
        </td>

这被传递到profiles.php

profiles.php具有通过形式的所有变量。...期望这一点。 我收到错误消息“通知:未定义的索引:文件”

这基本上是脚本中所有用于文件的...

    $target = "files/";

    echo $_FILES['file']['name'];
    //$image = basename($_FILES['file']['name']);
    //echo $image;
    $name = str_replace(' ', '_', $image);
    $target .= strtolower($name . uniqid());

    if(move_uploaded_file($_FILES['file']['tmp_name'], $target))
    {

    //echo $firstName, $lastName, $UserName, $email, $DOB, $join, $gender, $likes; 
//just a test to see if they were working.


addEntry($firstName, $lastName, $UserName, $Password, $email, $DOB, $join, $gender, $likes, $description, $newlike, $target);
    }

尝试将enctype =“ multipart / form-data”添加到html表单标签中。 即:

<form enctype="multipart/form-data">

您在<form>缺少enctype="multipart/form-data"

您很可能尚未在表单中定义文件上传元素'file'。

<input type="file" name="file" id="file" /> 

还要确保您的表单的enctype"multipart/form-data"

<form action="upload.php" method="post" enctype="multipart/form-data">

兄弟enctype="multipart/form-data"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM