2

Problem is my storing file directory is not working at all. If i could save Folders Direction i can show all files of folder.

create.blade.php

{!! Form::open(['method' => 'POST', 'route' => ['materials.store'], 'files' => true]) !!}
<div class="form-group">
    {!! Form::label('name', 'Файлаа энд хуулна уу') !!}
    {!! Form::file('attachments[]', ['roles' => 'form', 'multiple' => 'multiple']) !!}
    {!! Form::token() !!}
</div>
    {!! Form::submit('Submit', ['class' => 'btn btn-success'])  !!}
<a href="{{ url()->previous() }}" class="btn btn-default">Back</a>
{!! Form::close() !!}

materialscontroller@create

dd($request,$files);

config/app.php

'fileDestinationPath' => 'uploads',
'allowedFileTypes' => 'jpg,jpeg,bmp,png,pdf',
'maxFileSize' => 1000000*2,

Result is

"_token" => "9Oxhj6WrzJGAl3Dw8LV9cw6QvW7nT5PhittIiJL8"
"title" => "China"
"description" => "Deleniti nobis earum voluptatem facere quis eiusmod occaecat nostrum commodo soluta sit beatae nesciunt quia quasi"

Its show.blade.php thats how i print

<h1><b>Хэлтэс : </b> {{ $material->title }}</h1><hr> 
<p class="lead"><b>Агуулга : </b>{{ $material->description }}</p><hr>
@foreach($files as $file)
<a href="http://localhost/QuizApp/resources/app/{{ $file }}">Файл татах</br></a>
@endforeach

MaterialsController

foreach ($files as $file) {
$fileName = $file->getClientOriginalName();
$uploaded = Storage::put($destinationPath.$fileName.'.'.$file->getClientOriginalExtension(),file_get_contents($file->getRealPath()));
}
    if($uploaded){
        Material::create([
            'description' => $request->input('description'),
            'title' => $request->input('title'),
            'filename' => $date,
        ]);
6
  • What exactly is your question? Commented Mar 28, 2018 at 1:30
  • It almost works sir. I just cant save direction of folder . if i save direction of folder i can show all of files of that folder. Commented Mar 28, 2018 at 1:33
  • Can we see the code storing these files? Commented Mar 28, 2018 at 1:46
  • @Ohgodwhy edited sir take a look please. Commented Mar 28, 2018 at 1:55
  • What is the value of $destinationPath? if it's uploads then you're missing a directory separator (/) Commented Mar 28, 2018 at 2:53

1 Answer 1

1

Check your Model check your migrations then check destinationPath. I think your code is fine. Your Model is not working as good. I guess

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.