laravel安装和设置流程

来源:互联网 发布:java中sleep函数 编辑:程序博客网 时间:2024/06/05 02:36


http://laod.cn/hosts/2015-google-hosts.html   谷歌翻墙IP

1安装composer , VirtualBox和Vagrant

下载composer   https://getcomposer.org/download/

直接下载Composer-Setup.exe

点击下一步自动安装  path属性安装完后自动配置了path属性

下载VirtualBox:https://www.virtualbox.org/wiki/Downloads

 这个步骤很简单,如果中途弹出安装驱动的提示请选择“继 续安装”。部分用户安装完以后需要重启   

下载Vagrant:   http://www.vagrantup.com/downloads.html

装过程http://jingyan.baidu.com/article/f0e83a25a8fdb022e591012d.html

查看Vagrant的安装结果。

进入windows系统“命令提示符”界面,输入:vagrant 。

注:Vagrant安装过程中会自动配置环境变量。

添加Vagrant box

下载Homestead vbox:  两种方法可下载 建议使用迅雷下载  其他方法基本下不下来

1通过终端命令vagrant box add laravel/homestead https://atlas.hashicorp.com/laravel/boxes/homestead

2通过迅雷或浏览器新建下载输入地址

https://atlas.hashicorp.com/laravel/boxes/homestead/versions/0.2.7/providers/virtualbox.box

 

下载下来然后通过以下命令添加到vagrant

vagrant box add ./homestead.box 

例如:vagrant box add laravel/homestead F:\virtualbox.box 

          

./homestead.box 是box文件所在路径

我这里是直接 cd 到文件所在目录中执行命令的

 安装homestead命令行工具

通过composer安装homestead命令行工具

composer global require "laravel/homestead=~2.0"

然后执行homestead init会在 ~/.homestead/ 下面生成一个 Homestead.yaml 文件,你可以手动编辑它,也可以通过命令

 安装 Homestead

你可以简单地通过手动复制资源库的方式来安装 Homestead。将资源库复制至你的 "home" 目录中的 Homestead 文件夹,如此一来 Homestead 封装包将能提供主机服务给你所有的 Laravel(及 PHP)应用:

git clone https://github.com/laravel/homestead.git Homestead

一旦你克隆完 Homestead 仓库,从 Homestead 目录中执行 bash init.sh 命令来创建 Homestead.yaml 配置文件:

 

注:拉取时只能通过命令行拉去   否则拉取失败

 

注:执行时找到对应的E:\Homestead\homestead   init.sh位置

bash init.sh

此 Homestead.yaml 文件,将会被放置在你的 ~/.homestead 目录中。

C:\Users\lion\.homestead\Homestead.yaml

例子配置

ip: "192.168.10.10"

memory: 2048

cpus: 1

provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:

    - ~/.ssh/id_rsa

folders:

    - map: E:\Homestead\Code

      to: /home/vagrant/Code

sites:

    - map: homestead.app

      to: /home/vagrant/Code/weibao/public

databases:

    - homestead

variables:

    - key: APP_ENV

      value: local



配置host

 

在E:\Homestead\homestead 执行

vagrant up

 

 

 

 

1单元测试 

   "require-dev"加

phpunit/phpunit": "3.7.*"

更新composer update 

 

Artisan 命令行接口

      Php a@Rrtisan list 

         PHP ARTISAN list

     操作时必须到指定的项目中才可以执行

 

 

curl -sS https://raw.githubusercontent.com/grrnikos/pma/master/pma.sh | sh 

 

 

https://github.com/dbcli/mycli

 

 laravel-mongodb 安装

https://github.com/jenssegers/Laravel-MongoDB#installation

 

JohnLui/AliyunOSS v1.0 发布,附 Laravel 框架详细使用教程及代码

http://lvwenhan.com/laravel/425.html

 

//微信配置安装

https://github.com/overtrue/laravel-wechat

微信 SDK 2.0 文档,不再建议使用 1.x。

https://github.com/overtrue/wechat/wiki

启动虚拟机 

vagrant --version 查看版本

vagrant up (启动虚拟机)
vagrant halt (关闭虚拟机——对应就是关机)
vagrant suspend (暂停虚拟机——只是暂停,虚拟机内存等信息将以状态文件的方式保存在本地,可以执行恢复操作后继续使用)
vagrant resume (恢复虚拟机 —— 与前面的暂停相对应) 从新启动
vagrant destroy (删除虚拟机,删除后在当前虚拟机所做进行的除开Vagrantfile中的配置都不会保留)

 

把机器默认了“VirtualBox的提供者

bringing machine default up with 'virtualbox' provider

 

 

 

 

https://github.com/dbcli/mycli

 

 

 

这里特别注意空格和TAB  否则

 

错误页面

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

执行 vagrant provision

 

192.168.10.10  phpmyadmin.app

192.168.10.10  rockmongo.app

192.168.10.10  homestead.app

http://52113661.homestead.app/index

 

 

 

一、APT的使用(Ubuntu Linux软件包管理工具一)
apt-cache search # ------(package 搜索包)
apt-cache show #------(package 获取包的相关信息,如说明、大小、版本等)
sudo apt-get install # ------(package 安装包)
sudo apt-get install # -----(package - - reinstall 重新安装包)
sudo apt-get -f install # -----(强制安装?#"-f = --fix-missing"当是修复安
装吧...)
sudo apt-get remove #-----(package 删除包)
sudo apt-get remove - - purge # ------(package 删除包,包括删除配置文件
等)
sudo apt-get autoremove --purge # ----(package 删除包及其依赖的软件包+配置文件等(只对6.10有效,强烈推荐))
sudo apt-get update #------更新源
sudo apt-get upgrade #------更新已安装的包
sudo apt-get dist-upgrade # ---------升级系统
sudo apt-get dselect-upgrade #------使用 dselect 升级
apt-cache depends #-------(package 了解使用依赖)
apt-cache rdepends # ------(package 了解某个具体的依赖?#当是查看该包被哪些包依赖吧...)
sudo apt-get build-dep # ------(package 安装相关的编译环境)
apt-get source #------(package 下载该包的源代码)
sudo apt-get clean && sudo apt-get autoclean # --------清理下载文件的存档 && 只清理过时的包
sudo apt-get check #-------检查是否有损坏的依赖


apt-get install 的用法
apt-get install <package>
下载 <package> 以及所有倚赖的包裹,同时进行包裹的安装或升级.如果某个包裹被设置了 hold (停止标志,就会被搁在一边(即不会被升级).更多 hold 细节请看下面.

apt-get remove [--purge] <package>
移除 <package> 以及任何倚赖这个包裹的其它包裹.--purge 指明这个包裹应该被完全清除 (purged) ,更多信息请看 dpkg -P .

apt-get update
升级来自 Debian 镜像的包裹列表,如果你想安装当天的任何软件,至少每天运行一次,而且每次修改了
/etc/apt/sources.list 后,必须执行.

apt-get upgrade [-u]
升 级所以已经安装的包裹为最新可用版本.不会安装新的或移除老的包裹.如果一个包改变了倚赖关系而需要安装一个新的包裹,那么它将不会被升级,而是标志为 hold .apt-get update 不会升级被标志为 hold 的包裹 (这个也就是 hold 的意思).请看下文如何手动设置包裹为 hold .我建议同时使用 '-u' 选项,因为这样你就能看到哪些包裹将会被升级.

apt-get dist-upgrade [-u]
和 apt-get upgrade 类似,除了 dist-upgrade 会安装和移除包裹来满足倚赖关系.因此具有一定的危险性.

apt-cache search <pattern>
搜索满足 <pattern> 的包裹和描述.

apt-cache show <package>
显示 <package> 的完整的描述.

apt-cache showpkg <package>
显示 <package> 许多细节,以及和其它包裹的关系.

dselect, console-apt, aptitude, gnome-apt,是APT 的几个图形前端(其中一些在使用前得先安装).这里 dselect 无疑是最强大的,也是最古老,最难驾驭

 

 

1服务器Mongodb 扩展

更新源信息: sudo apt-get update

http://www.crifan.com/ubuntu_change_sources_list_to_163/

 

更新虚拟机数据源

 

更换数据源 

 

复制一份source.list

itotem@lm:~$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.apt

itotem@lm:~$ sudo vim /etc/apt/sources.list

#更替163源或者sohu源

itotem@lm:~$ sudo apt-get update

 

 

 

 

 

错误1 : key无法找到。

解决:

itotem@lm~$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys < add keys here >

itotem@lm:~$ sudo apt-get update

 

错误2  : GPG error: http://extras.ubuntu.com precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 16126D3A3E5C1192

 

解决

$gpg --keyserver keyserver.ubuntu.com --recv 3E5C1192

$gpg --export --armor 3E5C1192 | sudo apt-key add -

$sudo apt-get update

 

安装Apt-get install geidt

 

覆盖   cp到本地  再cp到服务器

#网易 Ubuntu 源(速度很快)

 deb http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse 

 deb-src http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse 

 deb http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted

 deb-src http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted

 deb http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted

 deb http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted

 deb-src http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted

 deb http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted

 deb-src http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted

 deb-src http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted

 

更新

sudo apt-get update

 

 

如果有权限设置  su回车 输入密码

安装mongo   redis 扩展

在php.ini中添加
extension=php_mongo.dll
extension=php_redis.dll
重启服务

 

服务器安装mongodb

$ ps -aux |grep mongo

Sudo Apt-get install mongo

 

 

Mysql “homestead” / “secret”。

php artisan migrate

 

 

mongodb扩展

 

Sudo Apt-get install php-mongodb

 

 

 

https://github.com/summerblue/phphub/blob/master/app/routes.php

 

 

 

 

 

 

1配置二级域名Homestead添加

 

2Host 添加二级域名

 

3输入vagrant provisition

 

 

 

 

Laravel框架大全

https://phphub.org/     搜索phphub

 

<a href="{{ action('UserController@edit',['id'=>1]) }}">

 

/* Route::any('/wechat', 'WechatController@serve');

/* Route::get('/', 'AgentController@index');

Route::get('/team',['as'=>'team','uses'=>'AgentController@team'] );

Route::resource('agent', 'AgentController');

 

 Route::resource('user', 'UserController'); 

 

Route::resource('agent', 'AgentController');

Route::get('agent/{name}', 'AgentController@index');

 

Route::get('/', function () {

    return view('welcome');

}); */

 

http://www.qcloud.com/wiki/COS-PHP-SDK%E8%AF%B4%E6%98%8E%E6%96%87%E6%A1%A3#1.1.09.E5.89.8D.E6.9C.9F.E5.87.86.E5.A4.87腾讯云存储

 

 


 

 



 

$share_wdlid =\Session::get('share_wdlid');
$qqq = \Request::input('share');
if($qqq ||  $share_wdlid){
    $friend trim(\Request::input('openid'));


 $where=array('type' => 'wdl');
   if($friend){
        $where ['openid'] = 'oqHjItwt4t0-hAZhc3NiwfhtUFTc';
    }else{
        $where ['openid'] = 'oqHjItwt4t0-hAZhc3NiwfhtUFTc';
    }
    $oinfo=AgentModel::whereRaw($where)->first();

    dump($oinfo);

 

 

 

 

 

/* $query = AgentModel::where('type', '=','wdl' );
 if($friend){
     $query->where('openid', '=','oqHjItwt4t0-hAZhc3NiwfhtUFTc');
 }else{
     $query->where('openid', '=','oqHjItwt4t0-hAZhc3NiwfhtUFTc');
    // $query->where('_id', '=',\Session::get('share_wdlid'));
 }
 $a = $query->first();
 dump($a);*/

 

 

 

 

$share_wdlid =\Session::get('share_wdlid');
$qqq = \Request::input('share');
if($qqq ||  $share_wdlid){
    $friend trim(\Request::input('openid'));


 $where=array('type' => 'wdl');
   if($friend){
        $where ['openid'] = 'oqHjItwt4t0-hAZhc3NiwfhtUFTc';
    }else{
        $where ['openid'] = 'oqHjItwt4t0-hAZhc3NiwfhtUFTc';
    }
    $oinfo=AgentModel::whereRaw($where)->first();

    dump($oinfo);

}

 

 

 

 

 

$user = PayingModel::where('_id','=',10)->first();
$user->status 1;
$user->save();

 

 

 

虚拟机导出

 

从这导出虚拟机Oracle VM VirtualBox   还有注意版本

 

系统包 文件包

安装vagrant 

C:  host文件

配置文件   项目   

Git  必须      SSH

 

 

 

//判断对象是否为空

function empty(obj){
    for(var in obj ){
        return false;
    }
    return true;
}

 

 

 

 

如果你的虚拟机已经处于运行状态了,可以通过使用命令vagrant reload --provision快速的重新启动虚拟机,命令中的--provision告诉Vagrant在重启的时候运行provisioners的配置,通常情况下,provisioners的配置只在执行vagrant up命令的时候才会执行。

 

 

Public  static  function  **(){

static  和 $this直接冲突

static  用于外界直接调用

不用static   只能在当前类下面调用

}


Glob  位置

 


https://github.com/overtrue/wechat微信公众平台

 

笔记



 

二级域名配置

 

 

 

 

安装memcache

sudo apt-get install php5-memcache

重启php5-fpm

sudo service php5-fpm restart

 

查看帮助

apt-get -h

升级mongodb 

apt-get upgrade mongodb

 

安装sudo apt-get install mongodb

开启关闭sudo service mongodb stop
  sudo service mongodb start

删除sudo apt-get purge mongodb

 

 

 

 

删除旧版本的Client

sudo apt-get remove mongodb-clientssudo apt-get autoremovesudo apt-get autoclean

 

设置数据库连接密码:

在跟目录创建文件夹: data/db

关闭现有服务。

    sudo service mongodb stop

重新启动服务

    $ mongod –auth

创建连接用户

    $ mongo

    > use admin

    switched to db admin

    > db.addUser("root","1983")

关闭服务(直接在 mongod 启动的命令窗口 “ctrl + C”

重启服务:

$: mongod –auth

查看是否开始验证:、

    $ mongo

    MongoDB shell version: 2.0.4

    connecting to: test

    > use admin

    switched to db admin

    > show collections

    Fri Mar 14 09:07:08 uncaught exception: error: {

    "$err" : "unauthorized db:admin lock type:-1 client:127.0.0.1",

    "code" : 10057

    }

有提示 链接错误。

进行用户验证:

    > db.auth("root","1983")

    1

重新查看就可以查看数据集

    > show collections

    system.indexes

    system.users

 

设置客户端连接:

默认安装的话只允许 127.0.0.1 IP 连接.

需要修改/etc/mongodb.conf 注释下列记录:

打开文件:

$ sudo gedit /etc/mongodb.conf

注释记录:

#bind_ip = 0.0.0.0 

 

 

 

 

 

 

 

Ipconfig 

vagrant provision

Mysql “homestead” / “secret”。

 

 

if($valid !== true){
    return $valid;
}

return response()->json(['code'=>0,'msg'=>"不好,申请大门被关了^_^"]);

 

 

 

 var $data $("form").serialize();
 var url ='';
$.get(url,{ datadata }, function (data) {
    if (data.code == 0) {
         alert(data.msg)
    }else if(data.code == 1){
        window.location.href="";
    }
}, 'json');*/

 

 

 

DB::collection('wdl_agent')->insert($data);

 

 

 

Laravel的使用

创建数据表

php artisan make:migration create_forms_attributes --create=forms_attributes

 

 

数据迁移 

php artisan migrate  只是生成数据表而已

 

填充数据据

 

执行php artisan db:seed

创建模型php artisan make:model Models/FormsAutomatic生成到对应目录

composer update --no-scripts  更新查找   

 --no-scripts: 跳过 composer.json 文件中定义的脚本

 

 

 

 

 

 

 

 

 

 

查看所有路由定向

vagrant@homestead:~/Code/platform$ php artisan route:list

 

创建控制器

:~/Code/platform$ php artisan  make:controller Admin/FormFieldController

 

 

 

Route::group(['prefix' => 'admin''namespace' => 'Admin''middleware' => 'auth'], function() { Route::get('/''AdminHomeComtroller@index'); Route::resource('pages''PagesController'); Route::resource('comments''CommentsController'); });

php artisan make:controller Admin/CommentsController

 

Index  update  destroy

 

public function index() return view('admin.comments.index')->withComments(Comment::all()); } public function edit($id) return view('admin.comments.edit')->withComment(Comment::find($id)); } public function update(Request $request, $id) $this->validate($request, [ 'nickname' => 'required''content' => 'required', ]); if (Comment::where('id'$id)->update(Input::except(['_method''_token']))) { return Redirect::to('admin/comments'); } else { return Redirect::back()->withInput()->withErrors('更新失败!'); } } public function destroy($id) $comment = Comment::find($id); $comment->delete(); return Redirect::to('admin/comments'); } }

 

php artisan make:model Article  php artisan make:model Page  

 

 

 

Continue结束单词循环

 

 

 

<div style="width100%; height50pxline-height50pxtext-aligncenter;">暂时商品信息</div>

 

 

 return Redirect::back()->withInput()->withErrors('更新失败!');

 

return Redirect::to('admin/comments');  返回

 

 

如果您想要覆写已存在的文件,可以使用 --force:

php artisan vendor:publish --force

 

 

 

 

Input::file('book')->getFileName();             // 缓存文件名Input::file('book')->getClientOriginalName();   // 客户端文件名Input::file('book')->getClientSize();           // 文件大小Input::file('book')->getMimeType();             // 文件类型Input::file('book')->guessExtension();          // 后缀名Input::file('book')->getRealPath();             // 真实缓存文件路径Input::file('book')->move('/storage/directory');    // 移动文件到指定文件夹Input::file('book')->copy('/storage/directory');    // 复制文件到指定文件夹Input::file('book')->rename('newName.pdf');         // 重命名

 

 

http://my.oschina.net/5say/blog/186455

 

 

 

 

 

 

 

 

 

 

 $timeline = DB::table('timeline_messages')->orderBy('id', 'desc')->paginate(10);
  return view('admin.timeline.index',['timeline' => $timeline]);  对象


 $timeline = TimelimeMessages::orderBy('id''desc')->paginate(10);
  return view('admin.timeline.index'['timeline' => $timeline]); 数组

  $timeline = TimelimeMessages::orderBy('id''desc')->paginate(10);
  return view('admin.timeline.index'compact('timeline') );  对象

 

 

http://platform.app/assets/global/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js

 

../../assets/global/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.js

 

 

<script>
    function submitit() {
        var tform1 document.getElementById("fileupload");
        var tform2 document.getElementById("formid2");
        tform1.submit();
        tform2.submit()
    }
</script>

 

 

 

代码修复

php artisan list

查找错误

php artisan sniff

自动修复

 php artisan sniff:fix

 

 

 

 

 

 

 2、MYSQL支持的数据引擎

  MyISAM:默认的MySQL插件式存储引擎,它是在Web、数据仓储和其他应用环境下最常使用的存储引擎之一。

  InnoDB:用于事务处理应用程序,具有众多特性,包括ACID事务支持。

  BDB:可替代InnoDB的事务引擎,支持COMMIT、ROLLBACK和其他事务特性。

  Memory:将所有数据保存在RAM中,在需要快速查找引用和其他类似数据的环境下,可提供极快的访问。

  Merge:允许MySQL DBA或开发人员将一系列等同的MyISAM表以逻辑方式组合在一起,并作为1个对象引用它们。对于诸如数据仓储等VLDB环境十分适合。

  Archive:为大量很少引用的历史、归档、或安全审计信息的存储和检索提供了完美的解决方案。

  Federated:能够将多个分离的MySQL服务器链接起来,从多个物理服务器创建一个逻辑数据库。十分适合于分布式环境或数据集市环境。

  Cluster/NDB:MySQL的簇式数据库引擎,尤其适合于具有高性能查找要求的应用程序,这类查找需求还要求具有最高的正常工作时间和可用性。

Other:其他存储引擎包括CSV(引用由逗号隔开的用作数据库表的文件),Blackhole(用于临时禁止对数据库的应用程序输入),以及Example引擎(可为快速创建定制的插件式存储引擎提供帮助)。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

取得配置值

$value = Config::get('app.timezone');

$value = config('app.timezone');

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

https://packagist.org/  中国镜像

 

 

判断是否存在这个数组

 $allowed  = array(

            'id',

            'level',

            'title',

            'status',

            'start_time'

        );

        $sort     = in_array(Input::get('sort'), $allowed) ? Input::get('sort') : 

 

 

 

 

 

  $rules array(
      'keyword' => 'required|email',
      'title' => 'required|between:1,20',
  );
  $message array(
      "required"             => ":attribute 不能为空",
      "between"      => ":attribute 长度必须在 :min 和 :max 之间"
  );

  $attributes array(
      "keyword" => 'guanjianzi',
      'title' => 'biaoti',
  );

  $validator = Validator::make(
      Input::all(),
      $rules,
      $message,
      $attributes
  );
  if ($validator->fails()) {
      $warnings $validator->messages();
      $show_warning $warnings->first();
     // return  \Response::Json(compact('show_warning'));

     // return $this->error($aa);
     // dump(compact('show_warning'));
      return compact('show_warning');
  }
 // return Response::Json("ok");

/*  $this->validate($request, [
          'keyword' => 'required',
          'title' =>'required',
      ]
  );*/

 

 

 

 

 

逆向查询

public function parentCity()    {        return $this->belongsTo('City', 'pid', 'id');    }

 

 

public function province()
{
    return $this->belongsTo('App\Models\Region''province''id');
}

public function city()
{
    return $this->belongsTo('App\Models\Region''city''id');
}

public function area()
{
    return $this->belongsTo('App\Models\Region''area''id');
}

 

 

 

public function hasPermission($key)
{

//静态表示存储     用来下次调用时直接返回数据      
    static $permissions;
    if (is_numeric($key)) {
        if (!$permissions) {
            $permissions $this->permissions()->getDictionary();
        }
        return isset($permissions[$key]);
    }
}

 

 

 

Route::getCurrentRoute()   //获取路由

 

 

  

 

 

没有找到路由

 

 

 

 

 

 

再依次运行以下命令

//清除composer.json
php artisan clear-compiled

php artisan optimize

composer update

 

 

 

 

 

 

 

从新迁移数据

php artisan migrate:refresh --seed

 

mysql -uhomestead -psecret

 

drop database platform;

 

 create database platform;

 Exit

 

 

 

 

http://daifu.platform.app/profile

二级域名    host 中写死  homestead “*.”

 

 

 

1、哈希算法往往被设计成生成具有相同长度的文本,而加密算法生成的文本长度与明文本身的长度有关。

 

2、哈希算法是不可逆的,而加密算法是可逆的。

 

 

如果您想要覆写已存在的文件,可以使用

编辑器   php artisan vendor:publish  

 

 

 

//w3c  菜鸟验证

http://www.runoob.com/jquery/jquery-plugin-validate.html

 

把图片发到imgContainer1上面

   var img = "<img src='' width='300' height='300' />";  

       $("#" + imgcontainerId).append(img);  

 

<div id="imgContainer1"></div> 

 

 

 

 

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@ include file="/base.jsp" %><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <base href="<%=basePath%>">        <title>ajax文件上传</title>        <meta http-equiv="pragma" content="no-cache">    <meta http-equiv="cache-control" content="no-cache">    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">     <meta http-equiv="expires" content="0">        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">    <meta http-equiv="description" content="This is my page">    <link rel="stylesheet" type="text/css" href="validate/ajaxfileupload.css" />    <script type="text/javascript" src="validate/jquery-1.6.2.min.js"></script>    <script type="text/javascript" src="validate/ajaxfileupload.js" ></script>    <script type="text/javascript">    $(function(){       //上传图片       $("#btnUpload").click(function() {               alert(ajaxFileUpload());       });    });    function ajaxFileUpload() {        // 开始上传文件时显示一个图片        $("#wait_loading").ajaxStart(function() {            $(this).show();        // 文件上传完成将图片隐藏起来        }).ajaxComplete(function() {            $(this).hide();        });        var elementIds=["flag"]; //flag为id、name属性名        $.ajaxFileUpload({            url: 'uploadAjax.htm',             type: 'post',            secureuri: false//一般设置为false            fileElementId: 'file', // 上传文件的id、name属性名            dataType: 'text', //返回值类型,一般设置为json、application/json            elementIds: elementIds, //传递参数到服务器            success: function(data, status){                  alert(data);            },            error: function(data, status, e){                 alert(e);            }        });        //return false;    }    </script>  </head>    <body>    <div id="wait_loading" style="padding: 50px 0 0 0;display:none;">        <div style="width: 103px;margin: 0 auto;"><img src="<%=path %>/images/loading.gif"/></div>        <br></br>        <div style="width: 103px;margin: 0 auto;"><span>请稍等...</span></div>        <br></br>    </div>    <input type="file" id="file" name="file"><br/>    <input type="hidden" id="flag" name="flag" value="ajax文件上传"/>    <input type="button" id="btnUpload" value="上传图片" />  </body></html>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<form >
    <input type="hidden" id="token" name="_token" value="<?php echo csrf_token()?>">
    <input type="hidden" id="userid" name="userid" value="{{$user->id}}">
    <input type="file" id="fileElem" name="fileElem" multiple accept="image/*"
           onchange="previewImage(this)">
    <button type="button" id="imgsubmit" class="btn btn-danger">提交</button>
</form>

<script>
    function previewImage() {
        var img $("#fileElem").val();//1347092855_407.jpg]
        if (img) {
            var formData new FormData($('form')[0]);
            $.ajax({
                url"profileimg",
                type"POST",
                dataformData,
                processDatafalse,
                contentTypefalse,
                successfunction (datatextStatusjqXHR) {
                    if(data.code==1)
                    {
                        var bigimg document.getElementById("fileList");
                        bigimg.src=data.url;
                    }
                },
                errorfunction (jqXHRtextStatuserrorThrown) {
                    //if fails
                }
            });
        }
    }
</script>

 

 

 

 

\Passport::makeUserLogin(3);

 

 

 

 

$(document).ready(function(){
    $('.cancel').click(function(){
        var action $(this).data('href');
        cust_confirm('提示','您确认取消该订单么?',function(){
            $.get(action,function(data){
                tips(data.message);
                if(data.status == 1){
                    location.href=data.return_url;
                }
            },'json');
        });
    });
});

 

 

http://laravelacademy.org/post/57.html

0 0
原创粉丝点击