Php download file db


















Do you use the windows versions? The file is opened in corrupted format. Do you checked the file size for the downloaded file? Tip: Open the file in your text editor, most of the time you can see an error message. Solve the the reported problem. Otherwise check also your PHP error log.

Thanks for the reply. But PDF, image file, txt file will download correctly for same code. I create a seperate controller for only download action.

So i find that it occur because of some other code affecting file. The bad thing is that headers work different for different server configurations. Hi Serge, you need to use the right headers. Check the example code for the PDF file. How to use this with. If you don't know the answer your don't answer for this. I'm terribly sorry for not fulfilling your high customer support quality standards and wasting your invaluable time with answers that do not work.

I'll be glad to offer a refund. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Helping communities build their own LTE networks.

Podcast Making Agile work for data science. First, we need to fetch the file info from the database. Open filesLogic. Now create a file called downloads. Now on this page, the files information from the database are listed each along with its size in KB and number of downloads. There is also a download button against each file.

What remains now is the code that actually downloads the file from our uploads folder. Let's write the code right away. So when you click on the download link of a file, that file's id is sent to the filesLogic.

Then we proceed to set some headers and finally respond with the file to the user using the readFile function in PHP. After the file is downloaded, we update the downloads count for that particular file in the database. That's about it with file upload and download. FYI — rapidwaters.

I've edited my answer. This code is not purely safe, but it will fit your needs, I assume. Thank you sooooo much. No problem. Please check my answer, if you liked it :- — barfoos. Show 2 more comments. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.

Post as a guest Name.



0コメント

  • 1000 / 1000