Download multiple files from local server using Ionic


#1

Hi , does anyone know on how to download multiple files from local server ? My serve is php…
I tried this for a month but i cant find any solution for my problem… please help me…


#2

could you provide us with more information?
like:

When you can provide more information, we can help you quicker.:wink:


#3

I’ve done a lot , i create file upload in PHP and save it into my mysql database…
I tried to retrieve the file from my database into my Ionic app… i search a lot , but i cant find any solutions…

I want the users can download a file like docx, ppt, txt, or pdf file…


#4

Please try this idea:

  1. install the FileTransferplugin

  2. make a php document that serves your database entries (provide it the document id (maybe also credentials) with get or post(post is probably more difficult, because you need to search in the filetransfer docs on how to do it, if it’s even possible)
    if your using nginx you can serve your file directly with a special header, so you don’t have to load it first in memory and save some resources and make it faster. ( make the file dir in your nginx config inacessible from the outside)
    (there should be an equivalent to this method in Apache, but i didn’t tested it jet (I use nginx))

  3. get the files via the file transferplugin from this php file.

The steps in your php file

1. (optional) sanitize user input just to be on the safe site
2.(optional) Check the credentials
3. get the file path from your database
4. serve the file with corresponding headers or use the nginx header methode

The nginx header that I mean: X-Accel-Redict
(just search it in your favorite search engine)

my header:


#5

Wow thank you for sharing your knowledge about this … i forgot to post my recent work of doing this, i create api in php then load it via json data, and display it in my app like this …

but i think it’s just like for the content of the page … but now i will do your idea, thanks for sharing this to me … it will help me a lot


#6

I will need to do this again for my app soon, I had it in my ionic v1 app, but I didn’t came to implement it in my new ionic v>2 app yet. So maybe you find out sth. new along you way that could help me, too. Maybe we should write a tutorial, when we have figured out a bulletproof solution. Im looking forward to hear how you will have solved it.
good luck and happy code tinkering.


#7

Hi sorry for late reply… yeah sure’ i can help you too… what version of Ionic do you have ? i started using Ionic in version 2 , but in my case have you done it before ? I still looking for a better solution about my problem , maybe the Ionic team should update their docs or write something about this…


#8

public s3 buckets with the files? or digital ocean spaces? firebase? or plain old file system with mysql like the aproach we talked earlier about?
Just keep tinkering around you will come to a working solution eventualy.

I have done it with pictures in ionic v1 in the future i need to do it again for my ionic 2/3 app, but I have some other things on this app, that have to get done first at the moment.


#9

Thank you for your suggestion… but first i will study first about ngInx because ngInx is new to me… i have no idea about ngInx… I already tried firebase but the results seems not what i want to do… so i tried a lot of things to solve my problem… but seriously thank you for helping me…