Skip to content
Advertisement

Uploading PDFs to a directory PHP

I’m uploading PDFs to a directory and my script works fine for one directory but I’m having troubles coming up with a way to write the script efficiently when I have more then one directory to upload PDFs on a page. I know of a few ways I can do it, like write another function like below but there must be a better way so I dont have to write out the whole script for every directory I want to upload PDFs to. Code below.

JavaScript

And of course the simple form

JavaScript

Thanks in advance for any suggestions.

Advertisement

Answer

If you’re okay with allowing users choosing which directory to upload to, you can give them the option.

JavaScript

Obviously, you would need to validate server-side for bad data.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement