0

When the user submit the form if there are any errors the fields should be populated with the submited values so the user dont need to insert theses values again. This is working fine but for the image field is not working.

I have the code below:

<form method="post" class="clearfix" action="{{route('post.store')}}" enctype="multipart/form-data">
    <div class="form-row">
        <div class="form-group col">
            <label for="image">Image</label>
            <label class="custom-file">
                <input type="file" id="file" name="image" value="{{ old('image') }}" class="custom-file-input">
                <span class="custom-file-control"></span>
            </label>
        </div>
    </div>
</div>

Do you know why the path of the image dont appear if there are any errors after the form is submited?

  • What do you mean? Are you trying to "preselect" a file from the local filesystem on behalf of the user? You can't do that – Alon Eitan Feb 16 '18 at 18:47

1 Answers1

0

No, the file input can't be prepopulated by Laravel or by any software. Your website (and any website) doesn't and shouldn't know the local path to the file. Imagine the security risks if they did! You could trick a user into uploading their SSH private key or something.

Reference https://stackoverflow.com/a/33158509/7809177

Prince Lionel N'zi
  • 2,510
  • 2
  • 12
  • 27