无法使用php表单上传.avi文件

时间:2015-05-18 09:43:45

标签: php html5 file-upload

尝试上传.avi视频格式,但页面只是刷新,文件没有上传所有其他类型的图片,所有内容都上传我发布我的代码在这里寻找文件uploding部分与cwf和ve

<?php
 $n=5;
     $exp_no="";
    $shot_no="";
    $file_name1="";
    $file_name2="";
    $remarks="";
    $cwf="";
    $vedio="";
        $conn=mysqli_connect("localhost","root","","project");
        if(!$conn){
             die("connection failed");
            echo "<br/>";
        }
        $query="select stage from experimentdetails where NO='{$exp_no}'"; 
        $res=mysqli_query($conn,$query);
        if(mysqli_num_rows($res)>0){
            $r=mysqli_fetch_row($res);
                    $n=$r[0];
        }

    session_start();
    $exp_no=$_SESSION["expno_add"];
    $s=mysqli_query($conn,"select ShotNo from shotdetails where ExpNo='{$exp_no}'");
    $res=mysqli_fetch_row($s);
    $shot_no=$res[0];
    if(isset($_POST["submit"]))
    {
        $remarks=$_POST["remarks"];
        $cap=array(8);
        $off=array(8);
        $cv=array(8);
        $cptp=array(8);
        $pul=array(8);
        $del=array(8);
        $vel=array(8);
        for($i=0;$i<8;$i++)
        {
            if($i<$n)
            {
                $j=$i+1;
                     $cap[$i]=$_POST["cv{$j}"];
                    $off[$i]=$_POST["off{$j}"];
                    $cv[$i]=$_POST["cc{$j}"];
                    $cptp[$i]=$_POST["cpt{$j}"];
                    $pul[$i]=$_POST["pw{$j}"];
                    $del[$i]=$_POST["del{$j}"];
                    $vel[$i]= $_POST["vel{$j}"];

            }
            else{
                    $cap[$i]=0;
                    $off[$i]=0;
                    $cv[$i]=0;
                    $cptp[$i]=0;
                    $pul[$i]=0;
                    $del[$i]=0;
                    $vel[$i]=0;
            }
        }
         if($_FILES['cwf']['name']!="")
        {
         $fname=$_FILES["cwf"];
           $uploaddir = 'cwf/'; 
          if (is_uploaded_file($fname['tmp_name'])) 
          { 
              $filname = basename($fname['name']); 
              $uploadfile = $uploaddir . basename($fname['name']); 
             if (move_uploaded_file ($fname['tmp_name'], $uploadfile)) 
                  $r = "File " . $filname . " was successfully uploaded and stored.<br>"; 
              else 
               $r = "Could not move ".$fname['tmp_name']." to ".$uploadfile."<br>"; 
          } 
           else 
               $r = "File ".$fname['name']." failed to upload."; 
           $file_name1='cwf/'.$file_name1;
        }
        if($_FILES['ve']['name']!="")
        {
         $fname=$_FILES["ve"];
           $uploaddir = 'upload/'; 
          if (is_uploaded_file($fname['tmp_name'])) 
          { 
              $filname = basename($fname['name']); 
              $uploadfile = $uploaddir . basename($fname['name']); 
             if (move_uploaded_file ($fname['tmp_name'], $uploadfile)) 
                  $r = "File " . $filname . " was successfully uploaded and stored.<br>"; 
              else 
               $r = "Could not move ".$fname['tmp_name']." to ".$uploadfile."<br>"; 
          } 
           else 
               $r = "File ".$fname['name']." failed to upload."; 
            $file_name2='upload/'.$file_name2;
        }
        $query="insert into shotdetails values($shot_no,$cap[0],$cap[1],$cap[2],$cap[3],$cap[4],$cap[5],$cap[6],$cap[7],$off[0],$off[1],$off[2],$off[3],$off[4],$off[5],$off[6],$off[7],$cptp[0],$cptp[1],$cptp[2],$cptp[3],$cptp[4],$cptp[5],$cptp[6],$cptp[7],$pul[0],$pul[1],$pul[2],$pul[3],$pul[4],$pul[5],$pul[6],$pul[7],$del[0],$del[1],$del[2],$del[3],$del[4],$del[5],$del[6],$del[7],$vel[0],$vel[1],$vel[2],$vel[3],$vel[4],$vel[5],$vel[6],$vel[7],$file_name1,$file_name2,$remarks,$exp_no,$cv[0],$cv[1],$cv[2],$cv[3],$cv[4],$cv[5],$cv[6],$cv[7])";
       mysqli_query($conn,$query);
    }
    mysqli_close($conn);
?>
<html>
    <head>
        <title>ADD Shot</title>
         <style>
    select {
        padding:3px;
        margin: 0;
        -webkit-border-radius:4px;
        -moz-border-radius:4px;
        border-radius:4px;
        -webkit-box-shadow: 0 3px 0 #ccc, 0 -1px #fff inset;
        -moz-box-shadow: 0 3px 0 #ccc, 0 -1px #fff inset;
        box-shadow: 0 3px 0 #ccc, 0 -1px #fff inset;
        background: #f8f8f8;
        color:#888;
        border:none;
        outline:none;
        display: inline-block;
        -webkit-appearance:none;
        -moz-appearance:none;
        appearance:none;
        cursor:pointer;
        }
        /* Targetting Webkit browsers only. FF will show the dropdown arrow with so much padding. */
        @media screen and (-webkit-min-device-pixel-ratio:0) {
        select {padding-right:18px}
        }
        label {position:relative}
        label:after {
        content:'<>';
        font:11px "Consolas", monospace;
        color:#aaa;
        -webkit-transform:rotate(90deg);
        -moz-transform:rotate(90deg);
        -ms-transform:rotate(90deg);
        transform:rotate(90deg);
        right:8px; top:2px;
        padding:0 0 2px;
        border-bottom:1px solid #ddd;
        position:absolute;
        pointer-events:none;
        }
        label:before {
        content:'';
        right:6px; top:0px;
        width:20px; height:20px;
        background:#f8f8f8;
        position:absolute;
        pointer-events:none;
        display:block;
        }
        .c ul li {
            margin-top: 11px;
        margin-right: 6px;
        padding: 0px;
        display: inline-block;
        font-family: open-sans, Araial, Helvetica, sans-serif;
        font-size:14px;

       }
       .c li a {

        margin-left: 10px;
    color:black;
        padding-right: 20px;

    text-decoration: none;
       }
       .c{
        margin-left: 20px;
    border-right: 1px solid rgba(1,1,1,0.20);
    border-left: 1px solid rgba(1,1,1,0.20);
    border-radius:5px;
        width:98%;
        margin-top: 10px;
       }
       #nav {
            height: 40px;
            border-radius:3px;
            background-color: #f2f2f2;
            border-bottom: 1px solid #ccc; 
            border-top: 1px solid #ccc;
        }
        </style>
    </head>
    <body>
        <div class="c">
        <ul  id="nav">
                <li style="border-right:1px solid rgba(1,1,1,0.65);">
            <a href="add_exp.php">Add Experiment</a> 
        </li>
        <li  style="border-right:1px solid rgba(1,1,1,0.65);">
            <a href="mod_exp.php">Modify Experiment</a>
        </li>
        <li style="border-right:1px solid rgba(1,1,1,0.65);">
            <a href="del_exp.php">Delete Experiment</a> 
        </li>
        <li style="border-right:1px solid rgba(1,1,1,0.65);">
            <a href="new_shot.php">Create New Shot</a>
        </li>
        <li style="border-right:1px solid rgba(1,1,1,0.65);">
            <a href="del_shot.php">Delete Shot</a>
        </li>
        <li style="border-right:1px solid rgba(1,1,1,0.65);">
            <a href="add_comp.php">Add Component</a>
        </li>
                <li style="border-right:1px solid rgba(1,1,1,0.65);">
            <a href="mod_comp.php">Modify Component</a>
        </li>
                <li style="border-right:1px solid rgba(1,1,1,0.65);">
            <a href="del_comp.php">Delete Component</a>
        </li>
    </ul>
    </div>
        <center style="margin-top:5%">
        <form action="add_shot1.php" method="POST" name="add" enctype="multipart/form-data">
           <table cellspacing="4" cellpadding="4" class="cap">
               <tr>
                   <th>Stage No.</th>
                   <th>Charging Voltage(kV)</th>
                   <th>Offset(mm)</th>
                   <th>Coil Current(kA)</th>
                   <th>Current Pulse Time period(ms)</th>
                   <th>Pulse Width(ms)</th>
                   <th>Delay(ms)</th>
                   <th>Velocity</th>
               </tr>
           <?php

               for ($x = 1; $x <= $n; $x++) {
                       echo "<tr>";
                       echo "<td align='center'>" . $x . "</td>";
                       echo "<td  align='center' ><input type='number' class='text' name='cv{$x}' value='' style=' height:30px;'/></td>";
                       echo "<td align='center'><input type='number' class='text' name='off{$x}' value=''style=' height:30px;'/></td>";
                       echo "<td align='center' ><input type='number' class='text' name='cc{$x}' value=''style=' height:30px;'/></td>";
                       echo "<td align='center' ><input type='number' class='text' name='cpt{$x}' value=''style=' height:30px;'/></td>";
                       echo "<td align='center' ><input type='number' class='text' name='pw{$x}' value=''style=' height:30px;'/></td>";
                       echo "<td align='center' ><input type='number' class='text' name='del{$x}' value=''style=' height:30px;'/></td>";
                       echo "<td align='center' ><input type='number' class='text' name='vel{$x}' value=''style=' height:30px;'/></td>";
                       echo"</tr>";
               } 
           ?>
                   <tr>
                        <td colspan='4'> Current wave form file: &nbsp;&nbsp <input type='file' name='cwf' value='' class='text'/> </td>
                   </tr>

               <tr >
                   <td colspan='4' >Video File: &nbsp;&nbsp;<input type='file' name='ve' value='' class='text'/></td>
                   <td></td>
                   <td></td>
               </tr>
               <tr>
                   <td>Remarks</td>
                   <td><textarea rows="10" cols="40" name="remarks" value=""></textarea></td>
               </tr>
               <tr>
              <td colspan=4 align='center'><input type="submit"  name="submit" value="submit"  /></td>
               </tr>
           </table>
         </form>
        </center>
       </body>
</html>

0 个答案:

没有答案