Topic: upload rename settings

i want to keep the original filename but also append some random characters at the start or end to keep it unique. How do i do this?

thanks

Re: upload rename settings

based on what was said here:

http://www.plupload.com/punbb/viewtopic.php?id=1385

and what i found in plupload.js

i think i just need to edit this bit to include the original filename whilst keeping a random prefix.  Can anyone help me with what i would need to put here? something a bit like this possibly?

guid:function(){

    var n=new Date().getTime().toString(32),o;
    for(o=0;o<5;o++){n+=Math.floor(Math.random()*65535).toString(32)
    }
    return(g.guidPrefix||"p")+n+(f++)+filename.toString(32)
    }

Re: upload rename settings

You are probably better off doing this outside of the plupload code itself.  The unique name is created in a UploadFile callback created by plupload.  If you create your own UploadFile callback, register it after your call to iniit() you can fiddle the target_file property of the file object.  Maybe something like this:

// Set unique_names: true in your config

pluploader.init();  // Your call to init.

// Sometime after the call to init()
pluploader.bind("UploadFile", function(up, file) {
    file.target_name = file.id + "-" + file.name;
});

I haven't tested this, so not sure it will work.

Re: upload rename settings

Dear Administrator,

I don't want to rename my uploading file. But now when i upload the file is renamed in upload directory. How to restrict file renaming. Waiting for your response. Thanks in Advance..

Re: upload rename settings

mike wrote:

I haven't tested this, so not sure it will work.

This actually sucks in a very teasing manner
The result is that chunks uploaded with proper name and the first part with what it is by default.
this results with 2 files instead of one - file.id . part and file.id+_+file.name . ext
I've tried to bind more related events and had no luck so here's my workaround (shame on you, pluploaders smile anyway I like your product)
-disable unique file names option
-do some binds (maybe redundant but that works fine) as follows:

$(document).ready(function(){
    uploader.init();


    function patchName(file){
            file.target_name = file.id + "___" + file.name;
            return file;
    }

    uploader.bind("FilesAdded", function(up, Files) {
        for(var j in Files){
            file=Files[j];
            file=patchName(file);
            Files[j]=file;
        }
    });

    uploader.bind("BeforeUpload", function(up, file, resp) {
        file=patchName(file);
    });

    uploader.bind("UploadFile", function(up, file) {
        file=patchName(file);
    });

    uploader.bind("ChunkUploaded", function(up, file, resp) {
        file=patchName(file);
    });

});

Re: upload rename settings

offtop: I'm very thankfull to the one who defined $ function in custom.html. it made me mad before I've found why jQuery won't work. Plus progress updater with "innerHTML" won't actually work in FF. it either show 0 either 100.

thanks for your great work guys!