简体   繁体   English

打开时显示空白网页

[英]It displays a blank web page when I open it

When I open up the web page, it just shows a blank page. 当我打开网页时,它只显示一个空白页。 Do you know why it is doing this? 你知道为什么会这么做吗? Could it be because of the [] in the $_SESSION? 可能是因为$ _SESSION中的[]吗? There is no javascript errors on error console and I don't php errors on screen. 错误控制台上没有JavaScript错误,屏幕上也没有php错误。

Below is the javascript code where the appending occurs: 以下是发生附加的javascript代码:

    <?php
    session_start();

    $idx = count($_SESSION ['fileImage'] - 1);
    $output = isset($_SESSION ['fileImage'][$idx]) ? $_SESSION ['fileImage'][$idx]['name'] : "";

    ?>

              function stopImageUpload(success){

              var imageNameArray = ['<?php echo $output ?>'];
              var result = '';



              if (success == 1){
                 result = '<span class="msg">The file was uploaded successfully!</span><br/><br/>';

                    for(var i=0;i<imageNameArray.length;i++)
            {
                 $('.listImage').append(imageNameArray[i]+ '<br/>');

             }

              }
              else {
                 result = '<span class="emsg">There was an error during file upload!</span><br/><br/>';
              }

        return true;

        }

Below is the php script where it uploads a file which is on another page from the javascript function above: 以下是php脚本,该脚本在其中上传文件,该文件位于上述javascript函数的另一页上:

        <?php

            session_start();

            $result = 0;
            $errors = array ();
            $dirImage = "ImageFiles/";


        if (isset ( $_FILES ['fileImage'] ) && $_FILES ["fileImage"] ["error"] == UPLOAD_ERR_OK) {

        $fileName = $_FILES ['fileImage'] ['name'];

        $fileExt = pathinfo ( $fileName, PATHINFO_EXTENSION );
        $fileExt = strtolower ( $fileExt );


        $fileDst = $dirImage . DIRECTORY_SEPARATOR . $fileName;

                if (count ( $errors ) == 0) {
                    if (move_uploaded_file ( $fileTemp, $fileDst )) {
                        $result = 1;


                    }
                }

            }

    $_SESSION ['fileImage'][] = array('name' => $_FILES ['fileImage']['name']);

            ?>

        <script language="javascript" type="text/javascript">window.top.stopImageUpload(<?php echo $result;?>);</script>
$idx = count($_SESSION ['fileImage'] - 1);

should be 应该

$idx = count($_SESSION ['fileImage']) -1 ;

var imageNameArray = new Array();
imageNameArray = <?php echo $output ?>;

should become 应该成为

var imageNameArray = ['<?php echo $output ?>'];

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

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