Forum
Rename file on upload
I want to allow an editor to upload a PDF and for this PDF to be renamed before saving to the server. Does Perch allow me to do this, and if so, how would I implement this?
I want to allow an editor to upload a PDF and for this PDF to be renamed before saving to the server. Does Perch allow me to do this, and if so, how would I implement this?
Perch will preserve the file name, unless a file with that name already exists. You can't specify a third option, no.
Is there any way the uploaded file name can be captured and fed into a database?
Yes, that happens. What are you trying to accomplish?
I have 3 areas on the website which allows for a regular upload of a PDF and there is a link to the PDF on the website page. My thinking was that if the PDF could be renamed on upload, the link reference could remain the same. As this isn't possible with Perch, my other idea was to save the PDF name to a database table which could then be queried and fed dynamically into the link.
Hello Helen,
Do you have a region on a page where an editor uploads a PDF and want to output a link to that PDF on another page?
Hi Helen
You can just output the path to the uploaded document and then you don't need to change the filename:
Yes, that is exactly what I want to do.
If you have a region with the key
My Region
on the page/my-page.php
:You can output the same region on other pages with
perch_content_custom()
like so:You can also specify a different template if you need to display it differently on the other pages:
That's brilliant. I'll have a go. Thank you so much!
This worked a treat. Thank you Hussein