CAT | 开发日志
Javascript | copy |? 01/**02 * 设置cookies03 */04function setCookie(c_name,value,expiredays)05{06 var exdate=new Date()07 exdate.setDate(exdate.getDate()+expiredays)08 document.cookie=c_name+ "=" +escape(value)+09 ((expiredays==null) ? "" : ";expires="+exdate.toGMTString())10}11/**12 * 获取cookies13 */14function getCookie(c_name)15{16 if (document.cookie.length>0)17 {18 c_start=document.cookie.indexOf(c_name + "=")19 if (c_start!=-1)20 {21 c_start=c_start + c_name.length+122 c_end=document.cookie.indexOf(";",c_start)23 if (c_end==-1) c_end=document.cookie.length24 return unescape(document.cookie.substring(c_start,c_end))25 }26 }27 return "";28}
Javascript | copy |? 1$(window).load(function() {2 $(’#hobby_anti_all’).click(function () {3 $(’input[name="list[]"]’).attr("checked",function(){4 if($(this).attr("checked")==false) return true;5 return false;6 });7 }) ;8 });
假如我们现在从一个页面中提交一个文件到PHP文件中处理,代码如下(省略了html提交页面) PHP | copy |? 01< ?php02 $filename = $_FILES[’userfile’][’tmp_name’];03 if($_FILES[’userfile’][’size’]<100) exit("请选择文件");04 $fp = fopen($filename, "rb");05 $picture = fread($fp,filesize($filename));06 $picture = base64_encode($picture);07 fclose($fp);08 $data[’p_pic’] = $picture;09 $data[’type’] = $_FILES[’userfile’][’type’];10 $data[’file_name’] = $_FILES[’userfile’][’name’];11 $data[’file_size’] = $_FILES[’userfile’][’size’];12 $data[’content’] = $_POST[’content’];13 $connect =MYSQL_CONNECT("localhost","root","") or die("Unable to connect to MySQL server"); 14 mysql_select_db( "test") or die("Unable to select database");15 $result=MYSQL_QUERY( "INSERT INTO (p_pic,type,file_name,file_size,filetype,content) VALUES16 [...]
