使生成的内容保持在页面上以进行多个用户通信?

时间:2015-12-30 21:31:49

标签: javascript php session-cookies forum

特别是此应用程序的addElement和addText函数。 我希望多个用户阅读彼此的帖子。 我还使用附带的getfile.php页面实现了图像上传。

     <?php 
    $pgHeading="Pyramid Image Board - A frontier of free speech"; 
    $pgDesc="An image board made from the ground up by an unqualified 
    programmer.";            
    $pgKeywords="Chan, Image Board, Trade media, Internet Talk"; 
    ?>
    <html>
    <meta name="description" content="<?php echo $pgDesc ?>"></meta> 
    <meta name="keywords" content="<?php echo $pgKeywords ?>"></meta> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    </meta>      
    <body>
    <header>
    <link rel="stylesheet"   href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
  <script>
  function addtext() {
  var newtext = document.myform.inputtext.value;
  document.myform.outputtext.value += newtext;
    }

  function addElement() {

   var ni = document.getElementById('myDiv');

   var numi = document.getElementById('theValue');

    var num = (document.getElementById('theValue').value - 1) + 2;

    numi.value = num;

     var newdiv = document.createElement('div');

     var divIdName = 'Post#' + num + ":";

     newdiv.setAttribute('id', divIdName);

    newdiv.innerHTML = (divIdName) + document.myform.inputtext.value;
    ni.appendChild(newdiv);
     }
      </script>
      <style>

      #LL {
       position: relative;
       color: #00AABB;
       }

       div {
       margin: 0 auto;
       color: black;
      border-radius: 8px;
       background: linear-gradient(white, white, gray);
       padding-top: 0px;
       width: 600px;
       height: 55px;
        }

       #fs {
       margin: 0 auto;
       border-radius: 9px;
       width: 603px;
       background: linear-gradient(white, grey, white);

        }

        .clearfix {
         overflow: auto;
          }

          #textbox {
          height: 90px;
          width: 560px;
          border-radius: 6px;
          margin-left: 18px;
          }

          #post {
          border-radius: 7px;
          position: relative;
          left: 437px;
          color: black;
          }

           #inforce {
           position: fixed;
           top: 24px;
           left: 14px;
            }
            </style>

            </header>
           <fieldset id="fs">
           <input type="hidden" value="0" id="theValue" />
            <legend id=LL>. .<span id="inforce">.</span>
            </legend>
        <form enctype="multipart/form-data" action="getfile.php"  method="post" name="myform">
     <textarea id="textbox" type="text" size="50" name="inputtext" />
     </textarea>

 <input type="file" name="uploadFile">
 <input type="hidden" name="MAX_FILE_SIZE" value="25000" />
 <input type="submit" value="Upload File">
     <button class="btn btn-info" id="post" onClick="addtext()">
        <a value="Add New Text" href="javascript:;" onclick="addElement()">
  POST
   </a>
     </button>
    </fieldset>
      <span>
       <div id="myDiv">

         </div>
        </form>
        </span>
        </form>
        </body>
        </html



        //and here is the getfile.php// 

        <html>
        <head>
        <title>Process Uploaded File</title>
        </head>
        <body>
        <?php
        if ( move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'], 
        "/home/ubuntu/workspace/uploads/{$_FILES['uploadFile'] ['name']}")  )
        {  print '<p> The file has been successfully uploaded </p>'; 
        header('Location:index.php');                    
              }
           else
             { 
        switch ($_FILES['uploadFile'] ['error'])
        {  case 1:
               print '<p> The file is bigger than this PHP installation    
                    allows</p>';    break;
        case 2:
               print '<p> The file is bigger than this form allows</p>';
               break;
        case 3:
               print '<p> Only part of the file was uploaded</p>';
               break;
        case 4:
               print '<p> No file was uploaded</p>';
               break;
                   }
                  }
              ?>
                 </body>
                  </html>

0 个答案:

没有答案