Это видео недоступно.
Сожалеем об этом.
PHP File Download | Download Any File using PHP
HTML-код
- Опубликовано: 15 авг 2024
- Hello Guys
Watch My Other Playlists:
PHP : • Insert data into MySQL...
NODEJS : • Node JS About it,How t...
HTML & CSS: • Create Google Amp Stor...
================ SOURCE CODE===============
LINK : www.dropbox.co...
===============================================
In this tutorial have shown how to download any file with any extension using PHP. There are a few simple steps and a small script using which we can download any file easily.
Hope It Helps!
Hope all is well.
I tried implementing this with a CSV file instead but when the csv is downloaded, the HTML code is also printed. Anyone knows how to resolve this?
A doubt,its work,without downloading image,i've tried downloading the php program file,but after downloading the notepad file, after i open, show a my wrote html file also, how to do it
When I tried it, it is downloading the download.php file, and not image .. plz help ☹️
Put anchor tag on image
it show "we don;t support this file format"
Which file format?
@@CodeFlix12 dear sir when download is complete the image i can't show its blank white
I am not getting it
what if I want to download the file in specific folder like "downloads"?
Thank you 🕺, but how do I set the content disposition if my file name contains special characters like &, + because I can’t download them though other files I’m able to. I would appreciate if you could help. Thank you 🙏
Try escape characters
The source code gave me an Warning: Cannot modify header information - headers already sent, please could you help me resolving this error. Thank You!
Did you use different headers than what are used in the code? Also, you mentioned warning, so is the code still running for you?
why i cant download my file? when i click the tag was always display a word in a different language? help me please for my capstone project. Godbless.
Can you mail me screenshots! I might understand your problem in a more better way then. It is working fine for others including me so
@@CodeFlix12 it wont work in cpanel. or it already upped.
@@CodeFlix12 But it works in localhost. What's the problem with that?
The problem is with the path given for the file in the cpanel then
Really you are awesome bro......i appreciate it....😉
I do everything for you all people who need solutions to problems easily. Thanks for always supporting and commenting! Appreciate a lot!
I know this video is outdated, but can you make a video on allowing to upload and download files of all sizes and types in php
It is not outdated sir, it still works. I already have a video on upload which works too
@@CodeFlix12 No need of this much codes just a download attribute is enough
Very good tutorial, but the files that can be downloaded are only photos.
document files such as (.pdf) and also compressed files such as
(.rar) cannot be downloaded.
can you tell me how to download (.rar) and (.pdf) files using php?
Try adding allowable extensions
@@CodeFlix12 how to add allowable extensions?
You can see it in the code
may i ask how to handle if file is cancel download and do something
You can make a handleCancel function which works on click of cancel button
@@CodeFlix12 can you make example please
@@ilhamfirnanda9482 brother we just need to add a function for on cancel click
hey bro , when i download image and open it . it would not open and give not supported msg;
Just try for one of my videos and see
Because I tried that
If that doest work just check for the extension you are putting in code
download
Download attribute html
♥️♥️
Dear brother is the procedure same if the download file is pdf not image
Yes the procedure is same
Very helpful. Thank you!
♥️♥️
thank u a lot, your tutorials are so helpfull. and some tutorial about file management please , thank u a lot
Yes i have made tutorials on file management you can check.. they are old.. if other than that u want any specific topic tutorial than u can comment here or mail me.
Thanks❤️
ah yess im already downloaded your tutorials about file managemet, can I ask, ,about sending files through gmal , because my thesis is about files management
Yes I will try to built something like that! Currently I am working on another topic of file management.
Hope that helps. Keep flixing 🙌
thank a lot , more powers to come😊
Hello, this code perfectly works on localhost but not working on live server, can you please help regarding that.
Output shows binary file.
The files are correctly uploaded on server?
@@CodeFlix12 yes correctly uploaded, with proper permission. But the problem is when i click download button, instead of downloading this file it's open in binary format.
Maybe try changing the extension of files
after downloading, the image is not displayed. what should i do
The path to the image might b wrong
Hello , for solutions this problem you can see my comment at the top. Thank you
This is a very helpful video.
Can you please also help me do a tutorial "after the users key in their id (eg 001), users can download the files that I uploaded in the database according to the id"
Thank you very much in advnace! :)
Thank you
CodeFlix do u have any suggestions for the tutorial I mentioned? Is it possible to do that?
@@hmonmoesatt7092 hey! I dont think brother exposing the ID to end users is a good idea, it is possible but harmful
in this case, what I mean by ID is just a unique number for them to get their own files ( I want my customers to download their files themselves instead of email to them) :D
tapi bagaimana cara kita linkkan agar file dapat di upload/download oleh setiap user tanpa di tampilkan ke user lain. sekali lagi terima kasih..!
Can you translate it to English please
Thanks before for your video , but any little error after download file , as shown the file its can't be open with message : error format. and I have solutions for this , and bellow its my code and really working fine :
$filename = basename($_GET['path']);
$filepath = './assets/file/berkas/' .$filename;
if(!empty($filename) && file_exists($filepath)) {
//Definisikan Header
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filepath));
ob_clean();
flush();
readfile($filepath);
exit;
}
I think the root cause problem is need to input header('content-length') because the size of file become increase if without that.
Thank you.
Try this for additional reference
WebApp - Login Form for Download Files
ruclips.net/video/rkZj-Sk-XzQ/видео.html
ruclips.net/video/2nyYtanYC4Y/видео.html
WOW..thank you sir, helps me alot...also Thanks to the uploader of this video @CodeFlix...Godbless
This Is Not working in Opera Version:65.0.3467.78
Is there any error coming or it is just not working
Hi from my other account.
My answer.
No it does not give any error...
I explain the situation below
I have 2 files namely index.php and downloadexcel.php.
In index.php i have a button which sends the session information to downloadexcel.php. The downloadexcel.php file gets the data from sql table and inserts into the excel file..
The code runs perfectly fine in Chrome, Firefox and IE.
But does not run in Opera.
When i Launch Opera And Click On the download button it downloads the file but this works only one time in Opera. When i click on the download button again it does not download the excel file this time. When i restart opera it works again but for one time only.
The headers i used in the downloadexcel.php file are as follows.
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') n
header ('Content-Disposition: attachement;filename="name.xlsx"');
What am i missing?
Is there any cache problem for opera?
Yes you are not missing anything. This is a browser related issue. Browser does not support this type of caching
@@CodeFlix12 what would i need to do to run it on Opera. As this is my project for a collage course which requires the project code to be compatible with all the main stream browsers.
Do i need to Change or Add A header?
Hey. I don't get explorer popup to choose download location
Make input type to file to do that
@@CodeFlix12 Fixed👍
♥️♥️
And what have I to do when i have the image in a folder
Thx bro i found the solution
Sure sir
Is it possible to do the downloading in the background?
It happens in bg once you click download
Can we use this only for pics?
For anything
in ur video u mentioned image1.jpg ........ but what if I used a form and I wrote my name and thats the name of the jpg which immediately created in the folder....I mean to say u dont know when u r writing the code that whats the name of the jpg will be....... in that case what should I write in the blank space???
click here
Just autofill it with php then
autofill???
can u plzz elaborate???
Bring the name from database and fill it
It will be dynamic then
@@CodeFlix12 can I contact u in person... email or whatsapp!?
Thank lot sir,,,
it will really help me , thanks dude
❤️❤️
@@CodeFlix12 😊
Thanks for the lessons
Always a pleasure sir!
very helpful. thanks a lot
♥️♥️
can u give me link to download this php script
On my website
thank you sir
❤️❤️
how i can do it for an apk? Because i don?t get any error but it doesn't download anything
The file location of apk would be wrong sir!
Sorry but it' s like in your video, it founds the file else i would have get an error. It doesn't start the download can you help me sir?
Sir if the location of the file is wrong it won't give an error
@@CodeFlix12 okay thank you, tomorrow i' ll check. 😊😊
Sure sir
thank you that was so helpful
❤️❤️
thank you sou much it work 👌👍
♥️♥️♥️
readfile($filepath);
over
addding;
ob_clean();
flush();
thanks
❤️❤️
I need upload mp3 . Can u help me tnx.
Upload?
will it download the other php files?
Yes
@@CodeFlix12 with source code inside it?
Yes
What not do do 101. WARING!!! excellent to download any file, I mean any system file!!! never trust user input, and make sure you just don't allow url params to decide full path of the file...
True, but somewhere we have to give user flexibility
@@CodeFlix12 You just need to point those things out very clearly as most "new" people just copy code without realising it or just add comments inside code when showing example
Hey. I don't get explorer popup to choose download location
Thanks
❤️❤️
@@CodeFlix12 can I write to you in telegram
Yes
@@CodeFlix12 give me your username
Search channel CodeFlix on telegram
will this work with 3 gb files?
It should but will take time
I'll try tomorrow thank yoi
♥️♥️
apk download is not working
it just says "file not found"
nvm i fixed it
Might be a problem in the path
Thank you so much for the concise video and explanation of how the codes work THANK YOU SO MUCH
♥️♥️
Thanks Sir ❤
You help me a lot 😍
May Allah Bless you Ameen
❤️❤️
Not working but thanks
Error?
🙍
👨🏻💻
Please hindi
😂
@@CodeFlix12 what sir
Can't
@@CodeFlix12 sir WhatsApp me 9508310294