localhost和服务器

时间:2017-07-03 12:25:19

标签: php laravel laravel-5

我在localhost上开发我的应用程序,然后将其转移到服务器端。

我遇到$path

的问题
$request->file('video')->move($path, $video);

在localhost上我必须使用:

$request->file('video')->move(
            public_path().'/assets/videos/tutorials\/', $video
        );

//the result of path on server side :"/home/yekidehi/demo/public/assets/videos/tutorials/"

但在服务器端我必须使用:

$request->file('video')->move(
            'assets/videos/tutorials/', $video
        );

//the result of path on server side: 'mydomain.com/assets/video/tutorials/'

我需要很多时间。因为每次我想在服务器上传我的代码,我都必须更改$path

有没有解决方案?

1 个答案:

答案 0 :(得分:1)

你可以把if条件检查环境是否为localhost,

/* --- Variables --- */
$columnAmount : 12; /* This is used to set the amount of columns that will be used for a responsive grid layout */
$green : #3E9633; /* Main green background colour used throughout site */
$white : #FFFFFF;
$grey : #444444;


/* --- General Styling --- */
aside{
  img{
    width: 75%;
    margin-botom: 20px;
  }
}
html{
  height: 100%;
}
.wrapper{
  padding-left: 10px;
  padding-right: 10px;
  padding-bottom:40px;
}
body{
  padding-bottom:50px;
  position: relative;
  background-color: $grey;
  color: $white;
  text-align: center;
  margin: 0;
  h1{
    text-align: center;
    color: $white;
    font-size: 3rem;
    text-decoration: underline;
  }
}
header{
  color: $white;
  overflow: hidden;
  background-color: $green;
  nav{
    .mobileNav{
    display: block;
    width: 100%;
    height: 40px;
    background: url(../Images/burger.png) no-repeat 98% center;
    cursor:pointer;
    }
    overflow:hidden;
    ul{
      list-style-type: none;
      margin: 0;
      padding: 0;
      li{
        display: inline-block;
        padding: 14px 16px;
        text-align: center;
        font-size: 150%;
        &:hover{
          background-color: $grey;
        }
        a{
          color: $white;
          text-decoration: none;
        }
      }
    }
  }
  h1{
    font-size: 5rem;
    text-align: center;
    margin-bottom: 0px;
    text-decoration: none;
  }
  h2{
    font-size: 3rem;
    text-align: center;
    margin-top: 0px;
  }
  h3{
    font-size: 2rem;
    text-align: center;
  }
}
footer{
  display: inline-block;
  position: absolute;
  left:0;
  bottom: 0;
  width:100%;
  height: 50px;
  background-color: $green;
}
/* --- Media Queries and General Layout--- */

.row{
  clear:both;
  width:100%;
}

.col{
  display:block;
  float:left;
  box-sizing: border-box;
  max-height:auto;
 }

@media screen and (max-width:480px){ /* Styling for mobile viewports */
  @for $i from 1 through $columnAmount{
    .mobile-#{$i}{
      width: 100% / $columnAmount * $i;
    }
    .offset-mobile-#{$i}{
       margin-left: 100% / $columnAmount * $i;
    }
  }
  header{
    nav{
      ul{
        background-color: $grey;
        height: 0;
        li{
          float:none;
          text-align: left;
          width: 100%;
          margin: 0;
          a{
            padding: 10px;
            border-bottom: 1px solid $white;
            display: block;
            margin: 0;
          }
        }
      }
    }
  }
  header nav ul.open{
    height: auto;
  }
}

@media screen and (min-width:481px) and (max-width:800px){ /* Styling for tablet viewports */
  @for $i from 1 through $columnAmount{
    .tablet-#{$i}{
      width: 100% / $columnAmount * $i;
    }
    .offset-tablet-#{$i}{
      margin-left: 100% / $columnAmount * $i;
    }
  }
  header nav a.mobileNav{
    display:none;
  }
}

@media screen and (min-width:801px){ /* Styling for desktop viewports */
  @for $i from 1 through $columnAmount{
    .desktop-#{$i}{
      width: 100% / $columnAmount * $i;
    }
    .offset-desktop-#{$i}{
      margin-left: 100% / $columnAmount * $i;
    }
  }
  header nav a.mobileNav{
    display:none;
  }
}

如果条件适用于localhost,则部分运行时它是实时服务器。希望你能理解。

谢谢