单击图像,该图片将显示在宽度为100%的新选项卡上

时间:2016-02-29 13:54:04

标签: php

大家好我已经制作了一些关于网页设计主持人的php页面,我的问题是,我从用户接收图像并将其保存到文件夹中并显示所有保存的图像与href图像链接但是,当我点击图片,它将只在浏览器中打开图像而不在任何页面中。 如何解决这个问题,请帮助我。

我的代码是。

            <html>
            <head>
            <link rel="stylesheet" type="css/text" href="style.css">
            <title>Uploading Files via PHP</title>
            </head>
            <body>
            <center><form action="file.php" method="post" enctype="multipart/form-data">
            <table border="2">
            <tr height="100"><td>Upload A file:</td>
            <td><input type="file" name="file"></td></tr>
            <tr height="100"><td>Click Upload File:</td><td><input type="submit" name="submit" value="Upload File"></td></tr>
            </table>
            </form></center>
            <?php
            if (isset($_POST['submit'])) {
                $name=$_FILES['file']['name'];
                $type=$_FILES['file']['type'];
                $size=$_FILES['file']['size'];
                $tmp=$_FILES['file']['tmp_name'];

                if ($name==''){
                    echo "<script>alert('Please Select a file from computer!')</script>";
                    exit();
                }
                if (($type == "image/jpeg") || ($type == "image/gif") || ($type == "image/png")) {
                    if (file_exists("images/" . $_FILES["file"]["name"])) {
                        echo "This file $name is already exist!<br> please try another one..";
                        exit();
                    }
                    if ($size <= 50000){
                        move_uploaded_file($tmp,"images/$name");
                        echo "<center><font color=red>File was uploaded successfully!</font><br>Uploaded Image is here<br><img src='images/$name'> </center>";
                    }
                    else {
                        echo "Size of the image $size is larger than 50kb and it's not allowed... <br> image size must be less than 50kb..";
                    }
                }
                else {
                    echo "$type this is not a valid type of file<br>only upload Jpeg, PNG and Gif images";
                }
            }
            ?>
            <div class="container">
                <div class="row">
                    <?php
                        $files = glob("images/*.*");
                        for ($i=0; $i<count($files); $i++)
                        {
                            $num = $files[$i];
                            echo '<div class="col-sm-4"><a href="/test/'.$num.'"onclick="fullwin()"><img src="'.$num.'" alt="random image" class="demo"/></a></div>';
                        }
                    ?>
                </div>
            </div>
            <script>
            function fullwin(){
            window.open("bigpage.php","bfs","fullscreen,scrollbars")
            }
            </script>
            </body>
            </html>

0 个答案:

没有答案