The first question asked on this forum. I looked at a lot of tutorials on downloading files in laravel, did exactly what they did, but the file does not load. It would be great if you could help me. I post all the relevant codes for this.
Here is my html code for entering files and other inputs
<div id="form" >
<div id="select" style="font-size:20px;">
{{ Form::open(['route' => 'gpa.science'])}}
<div id="youtubelink" style="font-size:20px;">
<p>শিরোনাম :</p>
<h22 > {{ Form::textarea('title', null, ['size' => '70x1']) }} </h22>
</div>
</br>
<div id="youtubelink" style="font-size:20px;">
<p>ইউটিউব ভিডিও লিঙ্ক :</p>
<h22 > {{ Form::textarea('videokey', null, ['size' => '70x1']) }} </h22>
</div>
</br>
<div>
<form action="" name="filea">
<input type="file" name="filea" enctype="multipart/form-data">
<input type="hidden" value="{{ csrf_token() }}" name="_token">
</div>
</form>
<div class="input-filed">
{{ Form::submit('Submit', ['class'=>'btn btn-primary right'])}}
{{ Form::close()}}
</div>
Here is my route
Route::post('/blog1', ['as'=>'gpa.science', 'uses' => 'PageController@blogafter']);
Now after submitting the button, this will go to this PageController. PageController Code:
<?php namespace App\Http\Controllers;
use DB;
use App\Quotation;
use Input;
use Illuminate\Http\Request;
use App\Filename; use Storage;
use Illuminate\Support\Facades\File;
use Illuminate\Http\UploadedFile;
class PageController extends Controller {
public function blogafter(Request $request){
if($request->hasFile('filea'))
{
dd('Got the file');
}
dd('No file');
return view('blogafter');
} }
Now the problem is that it does not receive any file. It always shows the file. If I do $request->all();
, it returns
videokey null
filea "working.sql"
Now can anyone tell me what is wrong in my code? Why I can’t upload files. I am using laravel 5.4.36 and php version 5.6.31
Yunus source
share