php - download pdf file without specifying the whole name -


I've got a button where users can download specific files. Each time I have to process the name of the file and it will be inserted into a variable, before giving it to the user to give the ready function. However, in many cases the file name is quite long and can change over time, so there are chances of errors in the future. So I was wondering if someone can pass something like / filedirectory/*.pdf or just specify only one part of the name and everything else can be done and then send it to readfile to download the PDF Given which is found in the example below?

  if (isset ($ _ POST ["submit"]) // We will output a PDF header ('content-type: application / pdf'); // it will be downloaded .pdf header ('content-dispute: attachment; filename =' download pdf ''); // whatever the name in pdf is readfile ('./panyedoryory / * .pdf'); # and // file 123 ... readfile ('./panyedoryory / 123 * .pdf');}  

You can use to list all PDF files and then you can select that name You want it and readfile it.

Example

  & lt ;? php foreach (globe ("* .pdf") as $ filename) {/ Do something with $ / file name}? & Gt;  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -