Using the date field of a form of the post to specify upload folder for file

Home Forums Quform WordPress Using the date field of a form of the post to specify upload folder for file

This topic is: resolved
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2753
    nickharambee
    Participant

    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

    #2778
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #2786
    nickharambee
    Participant

    Hi 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

    #2789
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #2810
    nickharambee
    Participant

    Thanks 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.
    #2825
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #2827
    nickharambee
    Participant

    Great!

    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.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy