Forums

Naming Upload Files

bsanker 30 Jun, 2015
How do we name the file uploads with V5? With version V4 we could use the file upload GH action. I need the file name to have a set title based on a form field [title]. I have tried to make it just the file name without the date but it returns errors.

Brad
GreyHead 01 Jul, 2015
Hi Brad,

If you scroll down the Files Upload action settings there is a 'File Name Code'box where you can set a custom name.

Bob
bsanker 01 Jul, 2015
Bob,

I have tried the file name box. I modified the default code to remove the date <?php return $filename; and I get the error attached.
GreyHead 01 Jul, 2015
Hi Brad,

What did you replace the date code with? If you left it blank then I think that you are creating (or trying to create) files with no name.

Bob
bsanker 01 Jul, 2015
Bob,

The default code returns the current date and the existing file name. So If I upload a file called test.pdf it saves it as 201507010841_test.pdf. I am looking for it to only save the file name test.pdf. so I deleted the date field and left the rest of the code.

The only code i am putting in the box is <?php return $filename;
GreyHead 01 Jul, 2015
Answer
Hi Brad,

I think that needs to be
<?php return $file_name;
with an underscore.

Bob
bsanker 01 Jul, 2015
Its amazing how the little things can be such a big problem. That worked. Thanks Bob.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount

{item:title} {images:#}