Home › Forums › Quform WordPress › Using the date field of a form of the post to specify upload folder for file
- This topic has 6 replies, 2 voices, and was last updated 11 years, 9 months ago by nickharambee.
- AuthorPosts
- February 10, 2013 at 9:24 pm #2753nickharambeeParticipant
Hi,
I am not sure if this post belongs in the feature request section or not. I have designed a form that submits expenses including a scan/photo of the receipt/expense document which is uploaded with the form. I am aware that I can use the {year} and {month} placeholders to generate folders for the upload, but this is the year and month at the time of upload, whereas I would like to use the year and month corresponding to the expense that I am entering (which are specified in a date entry). Is it possible to do this?
Also, a couple of related questions:
1. Is it possible to rename the files uploaded according to the date of the expense?
2. Rather than the ‘Upload File’ data generating the name of the file and the URL, is it possible to format the output as just the text ‘see file’ or words to that effect, which is a link to the URL of the file? Failing this, could the URL be a clickable link , rather than just text?
Thanks,
Nick
February 11, 2013 at 4:19 pm #2778AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
February 12, 2013 at 12:24 am #2786nickharambeeParticipantHi Ally,
That’s a very helpful response. Thanks. The upload path is now set just as I’d like it, and I amended the function for renaming the uploaded file so that the file is named in the form {year}_{month}_{day}. There are a couple of outstanding issues though:
1. If two files have the same name then your script appends 1_ , 2_, etc to the start of the filename. So that I can identify my files easily by date, I would like the numbers to be appended to the end of the filename, i.e. filename_1, filename_2, etc. I can see where the renaming is handled in your script (lines 1013-1024), but because the extension is included in $filename it isn’t straight forward to change this. What would be the simplest way of achieving the desired filenames?
2. For Item 2 above, I wasn’t just wanting the text of the filename to change to ‘View File’. What I was wanting is simply the text ‘View File’ which would be a hyperlink to the URL of the file (i.e. when clicked the uploaded file would be seen on a webpage). So either I need your script to just return the URL (without the space and brackets which are currently included in $fullPath), and I can wrap this in
<a href='[url]'>View File</a>
when constructing the table, or your script could be adapted to generate the HTML and enter it into the table (probably the more straight forward method).I hope this is clear, and thanks again for your help.
Nick
February 12, 2013 at 11:56 am #2789AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
February 12, 2013 at 11:49 pm #2810nickharambeeParticipantThanks again Ally. I will look in to issue 1 further. I feel confident that I will be able to sort this out.
Regarding issue 2 though, I am still a little confused. The code you are suggesting I use I already have in place, i.e.:
$value = array(
'url' => iphorm_get_wp_uploads_url() . '/' . $result['path'] . $filename,
'text' => 'View file',
'fullPath' => $fullPath
);
This generates an entry in the following format: View File (URL) – which doesn’t work as a hyperlink. I attach a screenshot of an example entry.
Nick
Attachments:
You must be logged in to view attached files.February 13, 2013 at 9:58 am #2825AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
February 13, 2013 at 12:03 pm #2827nickharambeeParticipantGreat!
By just using:
$value = array(
'text' => iphorm_get_wp_uploads_url() . '/' . $result['path'] . $filename,
'fullPath' => $fullPath
);
I just get the URL and nothing else which I can then use to build a hyperlink when creating the table on my page.
Thanks again for walking me through this Ally. QuForm is a great product, and with a service to match.
- AuthorPosts
- You must be logged in to reply to this topic.