views:

99

answers:

2

Hi guys,

I am stuck. I am using uploadify to upload multiple files to my s3 server. I would like to put each file into a folder that has a unique identifier. What I was hoping to do was to use this syntax to accomplish that (note uuid is a jquery plugin to generate uuids):

'onComplete'  : function(event,queueId,fileObj,response) {
   $('#fileInput').uploadifySettings('folder',$.uuid())
}

My issue is that when this callback gets called -- i not longer have access to $('#fileInput').uploadifySettings(x,y) i get that it is an undefined method ?!

Other uploadify settings of note:

'auto':  'true'
'multi': 'true'

and I am uploading directly to Amazon s3

Has anyone run into this? Ideas on how to solve?

Thanks!

+1  A: 

I hope I'm not completely misunderstanding your question.

Wouldn't it be very easy to do that on the server-side? You have to handle the upload on the server-side anyway, which usually involves in some way to fetch the uploaded file from a temporary location, make sure it's not evil, and then to copy it to its final resting place.

At that last copying step, you could easily introduce a uuid (in this case generated on the server side as well, I suppose).

Would that be a valid approach, or am I missing a requirement you have?

Thomas
Thanks for chiming in. I am actually uploading the files directly to Amazon s3, and while I could use callbacks to my server to move the file upon loading, it certainly would be easier to put them in right place to start. But -- only if it is possible!
Jonathan
@Jonathan: Ah, that's why you want to do it that way. I would still think it's possible to do it the way you've described, but it might require changing uploadify's innards, unless there's an event/option I have overlooked so far. I'm not sure if they would frown upon that. I won't be able to investigate further until tomorrow myself, but I'm curious to figure it out now. ;)
Thomas
Cool -- would love any insight -- I am not a javascript expert. Its weird how uploadifySettings behaves during its events. Thanks for your help.
Jonathan
+1  A: 

I solved this same problem as follows, by changing the scriptData "onSelect" so when you select a new file:

onSelect : function(){
            $('#images_upload_file').uploadifySettings("scriptData", {'yourvar': yourvalue });
        },

that seems to do the trick

Jorre