Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 当传送到heroku或其他计算机时,Laravel应用程序停止显示图像_Php_Mysql_Laravel_Web - Fatal编程技术网

Php 当传送到heroku或其他计算机时,Laravel应用程序停止显示图像

Php 当传送到heroku或其他计算机时,Laravel应用程序停止显示图像,php,mysql,laravel,web,Php,Mysql,Laravel,Web,我需要我的laravel应用程序的帮助。 当我在另一台计算机上传输应用程序或将其部署到heroku时, 图像无法显示,但它们在我的电脑上工作正常。 代码如下: //索引视图 @foreach ($posts as $post) <img src="storage/{{$post->image}}" width="200px" title=""> @endforeach 权限?文件夹是否存在?您是否运行了php artisan storage:link?@kerbholz感谢您

我需要我的laravel应用程序的帮助。 当我在另一台计算机上传输应用程序或将其部署到heroku时, 图像无法显示,但它们在我的电脑上工作正常。 代码如下:

//索引视图

@foreach ($posts as $post)
<img src="storage/{{$post->image}}" width="200px" title="">
@endforeach

权限?文件夹是否存在?您是否运行了php artisan storage:link?@kerbholz感谢您的快速响应,但这似乎不是问题所在。这是否回答了您的问题?如果检查页面源,图像URL是否正确?你能在浏览器上打开它吗?@Smankusors它确实显示了正确的url,并且在浏览器(在本地主机上)中显示,一旦我将其上传到heroku或传输到另一台电脑,图像就会停止显示。
public function index()
    {
        return view('posts.index')->with('posts', Post::all());
    }

public function store(Request $request)
    {
        $this->validate($request, [
            'title' => 'required|unique:posts',
            'description' => 'required',
            'content' => 'required',
            'image' => 'required|image',
            'published_at' => ''
        ]);

        $image = $request->image->store('posts');

        Post::create([
            'title' => $request->title,
            'description' => $request->description,
            'content' => $request->content,
            'image' => $image,
            'published_at' => $request->published_at
        ]);
        session()->flash('success','Post created successfully.');
        return redirect(route('posts.index'));
    }