File Upload Wildcards?

aboutimage 17 Jun, 2009
Is there a wildcard option for valid file types for file upload? I have a form that needs to accept a large number of file types, and there are 4 upload buttons, so my code currently looks like this for each file upload button:

file1:tif|csv|doc|epg|gif|tiff|jpg|odg|odp|ods|odt|pdf|png|ppt|swf|txt|xcf|xls|fon|zip|ai|psd|eps|qxd|cdr|cdt|pub|fh4|fh5|fh6|fh7|fh8|fh9|fh10|ind|indd{10000-1}

Is there a way to do wildcards? I really don't care what kind of file the user uploads, so something like this would be nice:

file1:???{10000-1}
GreyHead 17 Jun, 2009
Hi David,

There's no wild-card, there used to be a * in an earlier version but it was removed as it opens up a big security hole.

I think that it's probably possible to hack the core to allow an pre-approved list but I'm not sure where and my editor is misbehaving this morning. I'll look later once i have it fixed.

Bob
GreyHead 17 Jun, 2009
Hi David,

This is a slightly obscure workaround but seems to be OK. You can change the file uploads string in the Server-side Validation Box (that's the obscure bit but it's the only opportunity you have to make the change before the file uploads are processed).
<?php
$MyForm =& CFChronoForm::getInstance();
$MyForm->setFormParam('uploadfields', 'file_1:doc|pdf{1000-0}');
?>

You can put something short in the file-uploads box and then paste the full code in here and it will replace the code in the file uploads box.

This isn't a wild card but it does bring the string under PHP control and you can manipulate it more or less as you like.

Bob
aboutimage 17 Jun, 2009
Thanks, Bob. Now that I understand the reason you removed the wildcard, I think I'll just follow along with that wisdom (security is good) and suck it up. I've typed 'em in manually.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger