使用php在三个下拉的选定值上载文件

时间:2019-03-25 04:57:50

标签: php drop-down-menu

我想从三个下拉菜单中按特定选择上传文件。

例如:
如果选择了课程(vfx),教师(john),作业(1),则在提交文件时应将其上传到特定的文件夹或位置。

谢谢。

<form action="" method="post" enctype="multipart/form-data">
  <table width="1561" height="1441" border="0" align="center">

    <tr>
      <td height="505" align="center" valign="middle">
        <table width="500" border="0" align="center">
          <tbody>
            <tr>
              <td height="42" align="left">&nbsp;</td>
              <td colspan="2" align="left" valign="middle"><img src="download.jfif" width="167" height="151" alt="" /></td>
            </tr>
            <tr>
              <td height="42" align="left">Course</td>
              <td align="left" valign="middle">:</td>
              <td align="left" valign="middle">
                <select name="Course" size="0" required="required" id="Course">
                  <option disabled selected>Select</option>
                  <option value="animation">Animation</option>
                  <option value="vfx">Vfx</option>
                  <option value="graphic">Graphic Design</option>
                  <option value="first">F.y. Bsc</option>
                  <option value="second">S.y.Bsc</option>
                  <option value="third">T.y.Bsc</option>
                </select>
              </td>
            </tr>
            <tr>
              <td width="128" height="31" align="left">Assignment No.</td>
              <td width="27" align="left" valign="middle">:</td>
              <td width="331" align="left" valign="middle">
                <select name="assignment" size="0" required id="assignment">
                  <option disabled selected>Select</option>
                  <option value="one">Assignment 1</option>
                  <option value="two">Assignment 2</option>
                  <option value="three">Assignment 3</option>
                  <option value="four">Assignment 4</option>
                  <option value="five">Assignment 5</option>
                  <option value="six">Assignment 6</option>
                  <option value="seven">Assignment 7</option>
                  <option value="eight">Assignment 8</option>
                  <option value="nine">Assignment 9</option>
                  <option value="ten">Assignment 10</option>
                </select>
              </td>
            </tr>
            <tr>
              <td height="38" align="left">Faculty</td>
              <td align="left" valign="middle">:</td>
              <td align="left" valign="middle">
                <select name="Faculty" size="0" required id="Faculty">
                  <option disabled selected>Select</option>
                  <option value="john">john</option>
                  <option value="andrew">andrew</option>
                  <option value="juli">juli</option>
                  <option value="parkar">parkar</option>
                  <option value="other">Other</option>
                </select>
              </td>
            </tr>

1 个答案:

答案 0 :(得分:1)

首先,您必须在表单周围创建表单元素,如果您已经创建了表单,那么我正在考虑将其方法为POST并考虑按钮名称为 btn 和您的代码问题如下:

<?php
        //Enter your code here, enjoy!

if(isset($_POST['btn']) )
{
    // getting the values from the form
    $courseValue = $_POST['Course'];
    $assignment = $_POST['assignment'];
    $faculty = $_POST['Faculty'];

    // condition to check for file uploading
    if($courseValue =="vfx" && $assignment == "1" && $faculty == "john")
    {
        // code to upload file or some other actions

    }
}