Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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 现有图像未以编辑形式显示,无法在larvel(5.8)中更新_Php_Image_Laravel 5_Upload - Fatal编程技术网

Php 现有图像未以编辑形式显示,无法在larvel(5.8)中更新

Php 现有图像未以编辑形式显示,无法在larvel(5.8)中更新,php,image,laravel-5,upload,Php,Image,Laravel 5,Upload,我试图制作todo列表,其中显示更新表单其他字段值,但对于图像,该值从文件夹中读取,但不显示在输入字段中 除了这个问题,一切都正常 这将显示图像名称 我使用dd($task->img”)以检查值 edit.blade.php <label for="title">Task Title</label> <input type="text" value="{{$task->title}}" class="form-control"

我试图制作todo列表,其中显示更新表单其他字段值,但对于图像,该值从文件夹中读取,但不显示在输入字段中

除了这个问题,一切都正常

这将显示图像名称

我使用
dd($task->img”)以检查值

edit.blade.php

        <label for="title">Task Title</label>
        <input type="text" value="{{$task->title}}" class="form-control" id="taskTitle"  name="title" >
      </div>
      <div class="form-group col-6">
        <label for="description">Task Description</label>
        <input type="text" value="{{$task->description}}" class="form-control" id="taskDescription" name="description" >
      </div>
 <div class="form-group col-6">
        <label for="img">Task Image</label>
        <input type="file" value="{!! $task->img !!}" class="form-control" id="taskImg" name="img" >
      </div>

添加文件作为默认值对输入字段不起作用。 您可能希望在输入字段上方添加一个额外的div,如:

<div>
<p>Current image</p>
<img src="{!! asset($task->img) !!}">
<p>Upload new image:</p>
 <div class="form-group col-6">
        <label for="img">Task Image</label>
        <input type="file" class="form-control" id="taskImg" name="img" >
      </div>
</div>

我忘了包括enctype=“multipart/form data”,还有这个错误,您会发现的。谢谢您的回答。
<div>
<p>Current image</p>
<img src="{!! asset($task->img) !!}">
<p>Upload new image:</p>
 <div class="form-group col-6">
        <label for="img">Task Image</label>
        <input type="file" class="form-control" id="taskImg" name="img" >
      </div>
</div>
$path = $request->file('img')->store('images');
$task->img = $path;