【问题标题】:how to change laravel directory from storage/app/public to public/media如何将 laravel 目录从 storage/app/public 更改为 public/media
【发布时间】:2018-12-19 20:08:50
【问题描述】:

我想将服务器上的默认 laravel 配置从 storage/app/public 更改为 public/media。在 localhost 中,它与 storage:link 一起使用,但在服务器上,即使添加了符号链接,它也无法正常工作。下面是我的符号链接代码。

<?php symlink('/home/cemo/cem/storage/app/public','/home/cemo/public_html');

另外,如果我从 store 函数返回 public_path(),我会得到 /home/cemo/cem/public

this is the structure of my cpanel

以下是我使用图像干预的商店功能

public function store(Request $request)
{
    return public_path();

    $this->validate($request,[
      'title'=>'required|min:6',
      'body'=>'required'
    ]);

        if($request->hasFile('image')){
            $img = $request->file('image');
            $imgName = time().'-'.uniqid() . '.' . $img->getClientOriginalExtension();
        }
        else{
            $imgName = 'default.jpg';
        }

    $posts = new post;

    $posts->title = $request->title;
    $posts->body = $request->body;
    $posts->posted_by = $request->posted_by;
    $posts->status = $request->status;
    $posts->position = $request->position;
    $posts->image = $imgName;
    $posts->source = $request->source;


    $posts->save();

    $posts->tags()->sync($request->tags);

    if(!empty($img)){
        Image::make($img)->resize(1500,550)->save(public_path('/media/images/blog/'. $imgName));
      }

     $notification = array(
         'message' => 'Successfully created',
         'alert-type' => 'success'
     );
     return redirect(route('post.index'))->with($notification);
}

【问题讨论】:

  • /home/cem 与 /home/cemo 有效吗?
  • 你能用mod_write之类的代替吗?
  • @KamilG。我现在编辑了它
  • @fyroc 导致 500 内部服务器错误
  • 不应该吗? &lt;?php symlink('/home/cemo/cem/storage/app/public','/home/cemo/public_html/media');

标签: laravel-5


【解决方案1】:

在 config/filesystems.php 中

将数组更改为:

'root' => 'public/media',

【讨论】:

    猜你喜欢
    • 2021-10-06
    • 2016-10-28
    • 2020-06-05
    • 2021-11-07
    • 2021-06-07
    • 1970-01-01
    • 2016-08-19
    • 2020-10-23
    • 1970-01-01
    相关资源
    最近更新 更多