zoukankan      html  css  js  c++  java
  • php课堂2简单作业+文件上传之案例

    文件上传失败不理解之案例://成功啦

    upfile.php:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>无标题文档</title>
    </head>
    
    <body>
    <form action="listen.php" enctype="multipart/form-data" method="post">
        <label for="name">Name:</label><br />
        <input type="text" name="name" value="" /><br />
        <label for="email">Email:</label><br />
        <input type="text" name="email" value="" /><br />
        <label for="homework">Class notes:</label><br />
        <input type="file" name="homework" value="" /><br />
        <input type="submit" name="submit" value="Submit Homework" />
    </form>
    </body>
    </html>

     

    listen.php:

    <?php
    /**
     * Created by PhpStorm.
     * User: liaoxiaofeng
     * Date: 2017/3/14
     * Time: 16:34
     */
    header("Content-Type:text/html;Charset=utf-8");
    //设置一个常量
    define("FILEREPOSITORY","/uploadfile");
    echo "定义成功".FILEREPOSITORY;
    //证实文件已提交
    if(is_uploaded_file($_FILES['homework']['tmp_name'])){
        //是pdf文件吗
        if($_FILES['homework']['type']!="application/pdf")
            echo "<p>Class notes must be uploaded in PDF format.</p>";
        else{
            //将已上传文件移到最终目的地
            $name=$_POST['name'];
            $result=move_uploaded_file($_FILES['homework']['tmp_name'],FILEREPOSITORY.$_FILES['homework']['name']);
            echo "wobudong";
            if($result==1)
                echo "<p>File successfully uploaded.</p>";
            else echo "<p>There was a problem uploading the file.</p>";
        }
    }
    ?>

     

    php课堂2简单作业:

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
        <title>Document</title>
    </head>
    <body>
    <table border="1"  style="800px; align:center;">
        <tr>
            <td colspan="4" align="center">题目:某人有100,000元,每经过一次路口,需要交费,规则如下:当现金>50000时,每次交5%当现金< =50000时,每次交5000用PHP编程 计算该人可以经过多少次路口,还剩多少现金. </td></tr>
        <tr>
            <th  style="200px;">路口数</th>
            <th  style="200px;">现金</th>
            <th  style="200px;">需交路费</th>
            <th  style="200px;">结余</th>
        </tr>
        <?php
        echo "<tr><td colspan='4' align='center'>当现金大于等于50000时</td></tr>";
    
        $woyou=100000;
        $i=0;
        $lukou=0;
        while($woyou>50000){
            echo "<tr>";
            $i++;
            echo "<td align='center'>".$i."</td>";
            echo "<td align='center'>".$woyou."</td>";
    
            $jiaoqian=$woyou*0.05;
            //echo "大于5万时第".$i."次我交了".$jiaoqian."元路费。<br/>";
    
    
            echo "<td align='center'>".$jiaoqian."</td>";
    
            $woyou=$woyou-$jiaoqian;
            //echo "我还有".$woyou."元<br/>";
            echo "<td align='center'>".$woyou."</td>";
            $lukou++;
            echo "</tr>";
        }
        echo "<tr><td colspan='4' align='center'>当现金小于等于50000时</td></tr>";
    
        while($woyou<=50000&&$woyou>=5000){
            echo "<tr>";
            $i++;
            echo "<td align='center'>".$i."</td>";
            echo "<td align='center'>".$woyou."</td>";
    
            echo "<td align='center'>5000</td>";
            $woyou=$woyou-5000;
            //echo "我还有".$woyou."元。<br/>";
            echo "<td align='center'>".$woyou."</td>";
            $lukou++;
            echo "</tr>";
        }
    
    
        echo "<tr>
                    <td colspan='4' align='center' style='color:red;'>"."可通过".$lukou."个路口。"."</td>
                </tr>";
        //echo "有路口".$lukou."个。";
    
        ?>
    </table>
    
    </body>
    
    </html>

     

  • 相关阅读:
    struts2实现的简单的Trie树
    从源码总结struts2命名空间的匹配规则
    Knockout2.x:ko.dataFor()、ko.contextFor()使用
    Reporting Services可選參數設置
    在.net CF中設置DataGrid中列的寬度
    VB.net 簡體繁體轉化代碼
    在SQL語句中獲取錯誤信息
    VS 2005 使用 Crystal report 發生載入報表失敗
    Lazarus一個奇怪的設置
    怎样用wince设备创建快捷方式
  • 原文地址:https://www.cnblogs.com/liao13160678112/p/6549343.html
Copyright © 2011-2022 走看看