Jump to content

Download files from search or list


Recommended Posts

I have a need for users to be able to put in a search term and for Processwire to return a PDF file matching that term. It isn't complicated, if they put in 088 then I need to return a PDF named 088.pdf. 

My question is, how do I do that in Processwire without having to make a page for every PDF? There will be hundreds of them and they will all be updated each year. Ideally I would like for the file to be served from the file system, not the database. 

Do I just bypass Processwire for this and use straight PHP? If so, how do I use a processwire template for the look of the site, but use PHP for filesystem access and returning file paths? 


Link to comment
Share on other sites

8 hours ago, zoeck said:

i think you can use $files->find() 

"Find all files in the given $path recursively, and return a flat array of all found filenames"

Thank you, I was trying this but I was having a hard time giving it a $path that worked. If I give it a path from the root of the server (c:/temp in the case of running on my local machine) it seems to work. I don't want that though as I can't serve that up for someone to download. How can I get a accessible path? Something like /site/templates/files/maps/etc/?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...