Welcome Guest, Not a member yet? Register   Sign In
SWFUpload: Where to change filenames?
#1

[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!
#2

[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'] = ...
#3

[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....




Theme © iAndrew 2016 - Forum software by © MyBB