Forums

uploaded file name issue with radio buttons

rgpatton 10 Aug, 2009
I need to find out if this is possible. I am using Chronoform to upload files that all members of my league need access to. I have the radio buttons to select the different options. Example would be this: I run 6 different series in an online race league. Each series run a different mod. I have the different mods as radio buttons. So when they upload files, it puts it in the right folder, but the file names start with numbers, and the radio button info does not show up in the file name.
This is the form created from the wizard:
[attachment=1]upload menu form.jpg[/attachment]

In my folders, it names the files with a set of beginning numbers, and the radio info is not in the file name as shown below:
[attachment=0]FTP files.jpg[/attachment]

I use jxplorer for them to download them, but the file name with the numbers as listed below do not help, and I really need the radio buttons to be in there to be able to sort them. I am new to all of this, but I am looking to see if this is possible, or maybe I should be using a different method to get the end result I am looking for. Please advise. Thanks

Rich
nml375 10 Aug, 2009
Hi Rich,
Hope I got your question right..
If you are using a recent version of CF, there should be a setting named "FileName Format" under the File Uploads tab. This can be used to build a custom filename for your upload (by setting the value of the variable named $filename). The default value should be:
$filename = date('YmdHis').'_'.$chronofile['name'];

This sets the filename to the current date/time, followed by an underscore, and the name of the file, as provided by the remote client. As I'd understood, you'd rather want this to be the value of your select input, followed by the filename?

The quick approach would be to simply replace the date(..) command with JRequest::getString('select_1'). This, however, would be very dangerous, as this would allow malicious users to upload the file in other places..So we'll need to "clean" it first. Also, we'd probably still want the date in there..
$filename = JFile::makeSafe(JRequest::getString('select_1')) . '_' . date('YmdHis') . '_' . $chronofile['name'];


This should give you a name like "Aero88_20090810185123_MyAero88.cts.car".
/Fredrik
rgpatton 10 Aug, 2009
Thank you so much. I think you are getting what I need to do. The only thing I would need other than adding the selection buttons as part of the file name, is to completely lose the numbers in the file name. The only reason is that when I allow jxplorer to give access to members, they will see that big number instead of just the series and carfile name. I think that this is almost exactly what I needed. thank you. I will play with that and see how it goes. Thanks again. My other option, the more I think about it, would be to just run a seperate form for each series, and make them go to a series named folder inside of the chrono folder. This may do it too, but I will still need to lose all those numbers, or at least make them not visible in jxplorer, or another program that would let me show the files for download. They need to be able to sort them by series/mod so they are getting all the files for that mod and not loading the wrong files to their series folders in the game. I will keep you posted on the outcome of ow I handle it, and what did what I neeeded. Big thanks again.
Rich
nml375 10 Aug, 2009
Hi Rich,
That "big number" is actually the timestamp - which is mainly in place to avoid having two files ending up with the exact same name. In order to remove it, just drop the date('YmdHis') part.

/Fredrik
rgpatton 12 Aug, 2009
I have since upgraded to the latest version, and this work perfect now. Thank you for your help.
This topic is locked and no more replies can be posted.