hello... you r showing how to download file whic is located in databse ... but i want to download the result whic i got after performin a searchin g.. please help me .. thnaks in advance
+Amin Thank You. Datatype that I used here `id` int(11) NOT NULL AUTO_INCREMENT, `file_title` varchar(200) NOT NULL, `file_name` varchar(200) NOT NULL, `created_at` timestamp NOT NULL, `updated_at` timestamp NOT NULL, u can also find the sql file in following link gitlab.com/Bons/download-files-laravel5/blob/master/download_db.sql for upload file, u can get idea from this video ruclips.net/video/LVipmYUakOU/видео.html
I have a problem when i download file it appears whene i'm download it : failure: file not found what can cause the problem NB : i have all file stored on my database
Hey @joven sorry to help you that time, but if you still need then here is the video about multiple files download video ruclips.net/video/IA03QeE59Fk/видео.html
when i click the download button, it show up and then said " failed- No file " i wonder what went wrong ? is it because of the path ? then my path will be Project/storage/app/public/upload/{{$user1->upload}} ???
hi sorry, late reply.Hmm, I think it's happening because of the path. .in browser hold on the file and inspect and check what URL/path are u getting??is that match with your file location?? Project/storage/app/public/upload/{{$user1->upload}} can't your path ur path will be like Project/storage/app/public/upload/filename.extension i means Project/storage/app/public/upload/mina.doc Project/storage/app/public/upload/appli.pdf
This code is working off line but not in live... when i click on download button then it returns Failed - No file, but in folder where i store the file i have it...
hi +manikam do u check your download file path??? is it match with your actual path??go and check your file name by holding the mouse on the download icon or file, then right click and inspect. or can u share your live project link??
+Indra Greetings from bonstutorial. We appreciate that you have knocked us for help. We would like to help you but before that we need to know your problem precisely. Please send us the necessary data and description of your problem. Thank you for being with bonstutorial , stay tuned.
Hi saurav suppose ur files are located in projectname/public/download directory in Controller public function downfunc(){ $manuals = []; $filesInFolder = \File::files('download'); foreach($filesInFolder as $path) { $manuals[] = pathinfo($path); } // var_dump($manuals); $vvs=json_encode($manuals);//for easy to display in view i encode return view('download.viewfile',compact(''vvs')); } in view @foreach(json_decode($vvs) as $mm)
Download
@endforeach Note:here {{url('/')}} is ur root url like projectname/public ..{{$mm->dirname}} is the folder name that is download,{{$mm->basename}} is the file name with extension like abc.jpg ..so along these three it stand projectname/public/download/abc.jpg
compact() is PHP function.Here Laravel uses it to pass variables from controller to its View.There are also other ways like 'with' consider our code $downloads=DB::table('downloadpdf')->get(); return view('download.viewfile',compact('downloads')); 1.first $downloads=DB::table('downloadpdf')->get(); we fetch the data from 'downloadpdf' table and put this data in $downloads variable 2.then since we will use that $downloads variable in our view so we have to pass that ...so we used here compact function to pass data ...here compact('downloads') downloads is variable...but you have to careful when you will use compact ,do not use $ sign of variable .just use the rest part of the variable except $. return view('download.viewfile is our view that is download folder then viewfile.blade.php
in laravel here we are using blade temple that's why the file extension is .blade.php when you want to display data in blade view, u can wrap the variable in curly braces {{ }} $down->file_name is our variable ...$down is array which we passed from controller to view...to get only file_name we use $down->file_name...file_name is the table column name how did you get " file_name" , not " file_title " on database? i am confused about your second question...what is the actual problem ...can you explain your problem
Hello Sir, I'm getting an error which is I'm not able to download the actual file it shows failed-No file...what should be the datatype of column in database for file upload?
+priyesh here datatype of column file_name is string . do u inspect the download file??probably ur file href or full path is not right.i suggest you first try to inspect the download button and check if the source is right like yourpeoject/public/image/abc.txt u can also try this href="{{url('/')}}download/{{$down->file_name}}". like below
well I have used LONGBLOB as datatype because I have to upload various types of file...in HeidiSQL it show the file in binary form....onclick download button now i get failed-network error...and in my project/public/downloads folder is also empty...
listen +priyesh it does not matter what the type of data...u just need to get the file name plus file's extnsion along with full path ..i mean ur file full path that is yourproject/which_ever_directory_you_put_your_file/filename.file_extention for foreach loop is not creating repetative u can test it in controller $downloads=DB::table('table_name')->get(); var_dump($downloads); check what you get??
Hi +Andrei.see the following links ruclips.net/video/LVipmYUakOU/видео.html (if you wanna know how to upload file that case) stackoverflow.com/questions/35428876/how-to-store-and-retrieve-image-contents-from-the-database-using-laravel (see the answer part here) www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx from above links hope you might get some idea.thanks
Hi! that's me again !! when i click on Down load i get that erreur : NotFoundHttpException in RouteCollection.php line 145: and the url is : localhost/shareitbaby.io/public/index.php/up_file/74696.pdf but when i remove index.php in url it works . can you explain that. thanks !!
because ur file is located in the directory localhost/shareitbaby.io/public/up_file/74696.pdf ...so when u use localhost/shareitbaby.io/public/index.php/up_file/74696.pdf it does find the file thats why giving error
hi i did follow the tutorial here for upload single file: ruclips.net/video/LVipmYUakOU/видео.html This only store the information for file title and file itself, it doesn't store the created_at info. Is that it is caused by array save issue? $data = array('file_title' => $filetitle, 'filename' => $filename);
Look at what I have been looking for for over three months.
Instant subscription BONS
Awesome to read this.
Thanks a ton +Ben.
:D Feeling blessed.
Glad to have you on board!!
The pleasure is mine. Am glad you shared this.
hello... you r showing how to download file whic is located in databse ... but i want to download the result whic i got after performin a searchin g.. please help me .. thnaks in advance
Very nice tutorial..works excellent for Laravel 5.6 as well
thank you very much bro , exxelent job !!
for directory you can use $filedir = Storage::url('/maybe/custom/folder/inside/storage/app',$somevariable->attachment);
inside controller
nice tutorial.. can I know what is your data type for each colum
+Amin Thank You.
Datatype that I used here
`id` int(11) NOT NULL AUTO_INCREMENT,
`file_title` varchar(200) NOT NULL,
`file_name` varchar(200) NOT NULL,
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL,
u can also find the sql file in following link
gitlab.com/Bons/download-files-laravel5/blob/master/download_db.sql
for upload file, u can get idea from this video
ruclips.net/video/LVipmYUakOU/видео.html
thank you..
can I store it on database as blob? and download the file?
Thank you for an excellent tutorial!
very nice video.its working
Thanks buddy!!!
Your video is very useful.
Thanks that's very helpful for my
I have a problem when i download file it appears whene i'm download it : failure: file not found
what can cause the problem
NB : i have all file stored on my database
Hi, i need help here, instead of download single file, are we able to select multi files and download it?
Hey @joven sorry to help you that time, but if you still need then here is the video about multiple files download video
ruclips.net/video/IA03QeE59Fk/видео.html
it start the download but download fails.. what's the problem of it?
I can't download file - but it's show on footer tab => Failed-No file
X
Thank you so much
when i click the download button, it show up and then said " failed- No file " i wonder what went wrong ?
is it because of the path ?
then my path will be Project/storage/app/public/upload/{{$user1->upload}} ???
hi sorry, late reply.Hmm, I think it's happening because of the path. .in browser hold on the file and inspect and check what URL/path are u getting??is that match with your file location??
Project/storage/app/public/upload/{{$user1->upload}} can't your path ur path will be like
Project/storage/app/public/upload/filename.extension i means
Project/storage/app/public/upload/mina.doc
Project/storage/app/public/upload/appli.pdf
hello even i have the same problem
THX DUDE IT WORKS!
Great tutorial can you add a counter to each download ....thanks
+medoune cisse Many many thanks for your nice feedback...do you want to show counter with database or without database??
hey bro good tutor tnx soooooo much and for those who have "failed - no file " error just just add"/" befor download in "href" like this
td> Dowanload
This code is working off line but not in live... when i click on download button then it returns Failed - No file, but in folder where i store the file i have it...
hi +manikam do u check your download file path??? is it match with your actual path??go and check your file name by holding the mouse on the download icon or file, then right click and inspect.
or can u share your live project link??
hello sir. i have a problem when download file.
can help to resolve about the problem.
thanks
+Indra
Greetings from bonstutorial. We appreciate that you have knocked us for
help. We would like to help you but before that we need to know your
problem precisely. Please send us the necessary data and description of
your problem. Thank you for being with bonstutorial , stay tuned.
what if i store my file in app\storage of laravel instead of db how will i give the dir of that file..???
Hi saurav
suppose ur files are located in projectname/public/download directory
in Controller
public function downfunc(){
$manuals = [];
$filesInFolder = \File::files('download');
foreach($filesInFolder as $path)
{
$manuals[] = pathinfo($path);
}
// var_dump($manuals);
$vvs=json_encode($manuals);//for easy to display in view i encode
return view('download.viewfile',compact(''vvs'));
}
in view
@foreach(json_decode($vvs) as $mm)
Download
@endforeach
Note:here {{url('/')}} is ur root url like projectname/public ..{{$mm->dirname}} is the folder name that is download,{{$mm->basename}} is the file name with extension like abc.jpg ..so along these three it stand projectname/public/download/abc.jpg
thnks bt it is showing error ErrorException in CompilesLoops.php line 80:
Undefined offset: 1
what is that compact('downloads') at 3:33
compact() is PHP function.Here Laravel uses it to pass variables from controller to its View.There are also other ways like 'with'
consider our code
$downloads=DB::table('downloadpdf')->get();
return view('download.viewfile',compact('downloads'));
1.first $downloads=DB::table('downloadpdf')->get(); we fetch the data from 'downloadpdf' table and put this data in $downloads variable
2.then since we will use that $downloads variable in our view so we have to pass that ...so we used here compact function to pass data ...here compact('downloads') downloads is variable...but you have to careful when you will use compact ,do not use $ sign of variable .just use the rest part of the variable except $.
return view('download.viewfile is our view that is download folder then viewfile.blade.php
what is "{{$down->file_name}}" how did you get " file_name" , not " file_title " on database?
Can I use same folder of files upload and download?
in laravel here we are using blade temple that's why the file extension is .blade.php
when you want to display data in blade view, u can wrap the variable in curly braces {{ }}
$down->file_name is our variable ...$down is array which we passed from controller to view...to get only file_name we use $down->file_name...file_name is the table column name
how did you get " file_name" , not " file_title " on database? i am confused about your second question...what is the actual problem ...can you explain your problem
how we can upload pdf, doc and text files in laravel 5.5
+firoj Check this link for upload ruclips.net/video/LVipmYUakOU/видео.html
Hello Sir, I'm getting an error which is I'm not able to download the actual file it shows failed-No file...what should be the datatype of column in database for file upload?
+priyesh here datatype of column file_name is string . do u inspect the download file??probably ur file href or full path is not right.i suggest you first try to inspect the download button and check if the source is right like yourpeoject/public/image/abc.txt
u can also try this href="{{url('/')}}download/{{$down->file_name}}". like below
Download
well I have used LONGBLOB as datatype because I have to upload various types of file...in HeidiSQL it show the file in binary form....onclick download button now i get failed-network error...and in my project/public/downloads folder is also empty...
And one more thing my foreach loop is not creating repetative values in download.blade.view folder...
listen +priyesh it does not matter what the type of data...u just need to get the file name plus file's extnsion along with full path ..i mean ur file full path that is yourproject/which_ever_directory_you_put_your_file/filename.file_extention
for foreach loop is not creating repetative
u can test it in controller
$downloads=DB::table('table_name')->get();
var_dump($downloads);
check what you get??
would you share me link of your database for download...I will try to figure out from that still have the same problem so....
how can you put file in database?
Hi +Andrei.see the following links
ruclips.net/video/LVipmYUakOU/видео.html (if you wanna know how to upload file that case)
stackoverflow.com/questions/35428876/how-to-store-and-retrieve-image-contents-from-the-database-using-laravel (see the answer part here)
www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx
from above links hope you might get some idea.thanks
Hi! that's me again !!
when i click on Down load i get that erreur :
NotFoundHttpException in RouteCollection.php line 145:
and the url is :
localhost/shareitbaby.io/public/index.php/up_file/74696.pdf
but when i remove index.php in url it works .
can you explain that. thanks !!
because ur file is located in the directory localhost/shareitbaby.io/public/up_file/74696.pdf ...so when u use localhost/shareitbaby.io/public/index.php/up_file/74696.pdf it does find the file thats why giving error
thank you
It's my pleasure :d
upload github friend :)
Doesn't anyone speak anymore?
hi i did follow the tutorial here for upload single file: ruclips.net/video/LVipmYUakOU/видео.html
This only store the information for file title and file itself, it doesn't store the created_at info.
Is that it is caused by array save issue?
$data = array('file_title' => $filetitle,
'filename' => $filename);
Thanks that's very helpful for my
Thanks sabbar