CodeIgniter Forums
SWFUpload: Where to change filenames? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: SWFUpload: Where to change filenames? (/showthread.php?tid=17546)



SWFUpload: Where to change filenames? - El Forum - 04-08-2009

[eluser]Leon Stafford[/eluser]
Hi,

I have an app using multiple instances of SWFUpload (which is great, btw!).

I'm hoping someone with experience can tell me where to change the uploaded file(s)' names. ie to a random string or datestamp.

Cheers!


SWFUpload: Where to change filenames? - El Forum - 04-08-2009

[eluser]pistolPete[/eluser]
Have a look at this thread: http://ellislab.com/forums/viewthread/98622/
If you use the SVN version of CodeIgniter you can use this setting of the upload library to change the filename:
Code:
$config['file_name'] = ...



SWFUpload: Where to change filenames? - El Forum - 04-08-2009

[eluser]Leon Stafford[/eluser]
Thanks pistolPete!

The SVN version and the config worked a charm!

I wasn't getting the right reference back to my SWFUpload calling page's JS function, so changed:

Code:
function uploadSuccessShop(file, serverData) {
    try {
        var progress = new FileProgress(file, this.customSettings.progressTarget);
        progress.setComplete();
        progress.setStatus("Complete.");
        progress.toggleCancel(false);
        //alert("The file " + file.name + " has been delivered to the server");
        
        addImage("shop",file.name);
    
    } catch (ex) {
        this.debug(ex);
    }
}

to:

Code:
function uploadSuccessShop(file, serverData) {
    try {
        var progress = new FileProgress(file, this.customSettings.progressTarget);
        progress.setComplete();
        progress.setStatus("Complete.");
        progress.toggleCancel(false);
        //alert("The file " + file.name + " has been delivered to the server");
        
        addImage("shop",serverData); //changed this
    
    } catch (ex) {
        this.debug(ex);
    }
}

I think that was needed, otherwise it was just the cache fairies messing with me....