关于应用分析系统的难点1

1路径的替换以及绝对路径假设一个路径是$path=str_replace($rootPath,'',$_SERVER['DOCUMENT_ROOT]);//绝对路径

如果js的路径是以上写法那么其js中的写法为<?php echo $path;?>/source/js/header.js?version=<?php echo filetime('/source/js/header.js');?>

2 关于session值的存储以及退出登录js方法

html中代码

<div class="cunchu">

<div class="left"  >

<?php

echo $username;          // 用户名获取

?>

<div class='middle'>       //获取时间

<div id='showtime'></div>

<a href='<?php echo $path?>/login.php?name=quit' onclick="loginout()">     //退出

<div class="right_top"></div>

<div>

退出

</div>

</a>

js中接受数值的写法

showTime()定义时间

function showTime(){

var now=new Date();

var year=now.getFullYear();

var month=now.getMonth();

var date=now.getDate();

var day=now.getDay();

var week;

var arr_week=new Array("星期日",星期一“);

week=arr_week[day];

var time='';

time=year+"年”+month+"月"+date+"日"+""+week;

document.getElementById('showtime").innerHTML=time;

//退出登录

function loginout(){

$.ajax({

url:'';

type:"post',

data:{

act quit"

}success function(){
]

3 关于上传文件

html代码

<fom method="post' action="" enctype="multipart/form-data">

<input type="hidden" name="act" value="upload">

<input type="hidden" id="filename" name="filename">

<input type="hidden" id="filesize"  name="filesize">

<input type="file" id="file" name="file" style="postion:absolute;clip:rect(0 0 0 0 );"onChange='updateFile()">

<button type="button" class="btn btn-primary onclick="setResult()">确定</button>

js代码

var filename;//定义变量

//弹窗效果

$(function(){

if($("#filename").val()){

filename=$('#filename').val();

openDialog();

$('#uploadName').html(filename);

}

})

//上传文件方法


function updateFile(){
var file=$("#file").val();

if(file==""){

alert("请先上传文件");

return false;

}

var types=file.split(".");

var fix=types[types.length-1].toLowerCase();

if(fix !='exe' && fix !="apk")

alert("文件类型不正确");

$("#file").val("");

return false;

}

document.forms.items(0).submit;

 function serResult(){

url:"",

type:"post",

data:{

act:'setResult'

},

success:function(v){

$("#uploadName').html(v);

}

原文地址:https://www.cnblogs.com/mmore123/p/13262161.html