在很多项目中都会叫用户上传东西这些的,自从接触了jquery 和ajax之后就不管做什么,首先都会想到这个,我这个人呢?是比较重视客户体验的,这次我这边负责的是后台板块,然后就有一块是要求用户上传照片的,当然就想到了无刷新上传了呀,一般的jquery+ajax的话传递给php的data我习惯用json,然后就不知道怎么怎么把$_FILES数组中的内容给php,我要用move_uploaded_file这个函数来吧$_FILES['file']['tmp_name']移动到我想要的位置,tmp_name是上传的临时路径了啦,具体参看手册,数组中有很多关于文件的记录的。查询了很多记录,要达到无刷新上传,那么有的解决方法是用生成frame来做得,找了很久很久,找到一个插件,jquery的,叫jquery.form,是个表单插件,有兴趣的同学可以上网查看,我这里只说我这个的实现而已,ok,上代码:
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>jQuery+php实现ajax文件上传</title>
6 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
7 <script type="text/javascript" src="/blog_article/jquery.form.js"></script>
8 <style type="text/css">
9 .opacity{
10 opacity:0.3;
11 filter:alpha(opacity=30);
12 background-color: black;
13 }
14 .mask{
15
16 position:fixed;
17 _position:absolute;
18 top:0;
19 left:0;
20 z-index:1000;
21 }
22 #main{
23 width:980px;
24 margin:0px auto;
25 text-align:center;
26 }
27 #loading{
28 background-color:white;
29 width:100px;
30 height:20px;
31 position:fixed;
32 _position:absolute;
33 text-align:
use Zend\Db\Sql\Select;
// basic table
$select0 = new Select;
$select0->from('foo');
// 'SELECT "foo".* FROM "foo"';
// table as TableIdentifier
$select1 = new Select;
$select1->from(new TableIdentifier('foo', 'bar'));
// 'SELECT "bar"."foo".* FROM "bar"."foo"';
// table with alias
$select2 = new Select;
$select2->from(array('f' => 'foo'));
// 'SELECT "f".* FROM "foo" AS "f"';
// table with alias with table as TableIdentifier
$select3 = new Select;
$select3->from(array('f' => new TableIdentifier('foo')));
// 'SELECT "f".* FROM "foo" AS "f"';
// columns
$select4 = new Select;
$select4->from('foo')->columns(array('bar', 'baz'));
// 'SELECT "foo"."bar" AS "bar", "foo"."baz" AS "baz" FROM "foo"';
// columns with AS associative array
$select5 = new Select;
$select5->from('foo')->columns(array('bar' => 'baz'));
// 'SELECT "foo"."baz" AS "bar" FROM "foo"';
// columns with AS associative array mixed
$select6 = new Select;
$select6->from('foo')->columns(array('bar' => 'baz', 'bam'));
// 'SELECT "foo"."baz" AS "bar", "foo"."bam" AS "bam" FROM "foo"';
// columns where value is Expression, with AS
$select7 = new Select;
$select7->from('foo')->columns(array('bar' => new Expression('COUNT(some_column)')));
// 'SELECT COUNT(some_column) AS "bar" FROM "foo"';
// columns where value is Expression
$select8 = new Select;
$select8->from('foo')->columns(array(new Expression('COUNT(some_column) AS bar')));
// 'SELECT COUNT(some_column) AS bar FROM "foo"';
// columns where value is Expression with parameters
$select9 = new Select;
$select9->from('foo')->columns(
array(
new Expression(
'(COUNT(?) + ?) AS ?',
array('some_column', 5, 'bar'),
array(Expression::TYPE_IDENTIFIER, Expression::TYPE_VALUE, Expression::TYPE_IDENTIFIER)
)
)
);
// 'SELECT (COUNT("some_column") + ?) AS "bar" FROM "foo"';
// array('column1' => 5);
//
// 'SELECT (COUNT("some_column") + \'5\') AS "bar" FROM "foo"';
// joins (plain)
$select10 = new Select;
$select10->from('foo')->join('zac', 'm = n');
// 'SELECT "foo".*, "zac".* FROM "foo" INNER JOIN "zac" ON "m" = "n"';
// join with columns
$select11 = new Select;
$select11->from('foo')->join('zac', 'm = n', array('bar', 'baz'));
// 'SELECT "foo".*, "zac"."bar" AS "bar", "zac"."baz" AS "baz" FROM "foo" INNER JOIN "zac" ON "m" = "n"';
// join with alternate type
$select12 = new Select;
$select12->from('foo')->join('zac', 'm = n', array('bar', 'baz'), Select::JOIN_OUTER);
// 'SELECT "foo".*, "zac"."bar" AS "bar", "zac"."baz" AS "baz" FROM "foo" OUTER JOIN "zac" ON "m" = "n"';
// join with column aliases
$select13 = new Select;
$select13->from('foo')->join('zac', 'm = n', array('BAR' => 'bar', 'BAZ' => 'baz'));
// 'SELECT "foo".*, "zac"."bar" AS "BAR", "zac"."baz" AS "BAZ" FROM "foo" INNER JOIN "zac" ON "m" = "n"';
// join with table aliases
$select14 = new Select;
$select14->from('foo')->join(array('b' => 'bar'), 'b.foo_id = foo.foo_id');
// 'SELECT "foo".*, "b".* FROM "foo" INNER JOIN "bar" AS "b" ON "b"."foo_id" = "foo"."foo_id"';
// where (simple string)
$select15 = new Select;
$select15->from('foo')->where('x = 5');
// 'SELECT "foo".* FROM "foo" WHERE x = 5';
// where (returning parameters)
$select16 = new Select;
$select16->from('foo')->where(array('x = ?' => 5));
// 'SELECT "foo".* FROM "foo" WHERE x = ?';
// array('where1' => 5);
//
// 'SELECT "foo".* FROM "foo" WHERE x = \'5\'';
// group
$select17 = new Select;
$select17->from('foo')->group(
Php simplexml 添加节点
原始代码如下
//================
<?
//创建xml对象
$xml = new SimpleXMLElement('<Messages></Messages>');
for($i=0;$i<10;$i++)
{
$xml->message[$i] = ''; //新节点
$xml->message[$i]['id'] = "id".$i;
$xml->message[$i]->title = "title".$i;
$xml->message[$i]->content = "content".$i;
$xml->message[$i]->time = "time".$i; //根据消息id 查询它相关的回复信息
}
$xml->message2[0] = "";
$xml->message2[0]->title1="this is new att";
//$xml->asXML('messages.xml');
//直接输出成xml内容
echo $xml->asXML();;
?>
//===========================
也就是说如果要添加新的节点,不需要执行任何函数,直接用
$xml->message2[0] = "";就可以得到新的节点。
同样,添加新的属性也是不需要任何函数,直接用新的成员。
比如
$xml->message2[0]->title1="this is new att";
本文链接:http://www.cnblogs.com/stevenlaz/p/3245822.html,转载请注明。