Skip to content

Instantly share code, notes, and snippets.

@fabrikagency
Created September 16, 2010 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabrikagency/583098 to your computer and use it in GitHub Desktop.
Save fabrikagency/583098 to your computer and use it in GitHub Desktop.
Gdn_MultiFileUpload.prototype.NewUploader = function() {
var NewUploaderID = null; var AutoShow = false;
if (this.CurrentInput == null) {
NewUploaderID = 1;
} else {
AutoShow = true;
NewUploaderID = parseInt(this.CurrentInput.split('_').pop()) + 1;
}
NewUploaderID = [this.AttachFileRootName,NewUploaderID].join('_');
var UploaderForm;
var Action = ['post','upload',NewUploaderID];
if (this.ActionRoot)
Action.unshift(this.ActionRoot);
Action.unshift('');
var IFrameName = this.NewFrame(NewUploaderID);
var FormName = IFrameName+'_form';
if (jQuery.browser.msie) {
UploaderForm = document.createElement('<form action="' + Action.join('/') + '" method="POST" enctype="multipart/form-data" class="FileUpload" id="' + FormName + '" target="' + IFrameName + '" />');
} else {
UploaderForm = $('<form />').attr({
enctype:'multipart/form-data',
method:'POST',
id:FormName,
target:IFrameName,
action:Action.join('/')
}).addClass('FileUpload')[0];
}
if (this.APC) {
var APCNotifier = document.createElement('input');
APCNotifier.type = 'hidden';
APCNotifier.name = 'APC_UPLOAD_PROGRESS';
APCNotifier.id = NewUploaderID+'_apckey';
APCNotifier.value = this.UniqID + '_' + NewUploaderID;
$(UploaderForm).append(APCNotifier);
}
var NewUploader = document.createElement('input');
NewUploader.type = 'file';
NewUploader.name = NewUploaderID;
NewUploader.id = NewUploaderID;
NewUploader.className = '';
NewUploader.rel = FormName;
$(UploaderForm).append(NewUploader);
var MaxUploadSize = document.createElement('input');
MaxUploadSize.type = 'hidden';
MaxUploadSize.name = 'MAX_UPLOAD_SIZE';
MaxUploadSize.value = this.MaxUploadSize;
$(UploaderForm).append(MaxUploadSize);
$(this.CurrentUploader).append(UploaderForm);
this.CurrentInput = NewUploaderID;
this.ProgressBars[NewUploaderID] = {
'Target': IFrameName,
'Filename': '',
'TimerID': 0,
'ApcKey': this.UniqID + '_' + NewUploaderID,
'Progress': 0,
'Size': 0,
'Complete': false
};
if (AutoShow)
this.ShowUploader(true);
$('#'+this.CurrentInput).change(jQuery.proxy(this.DispatchCurrentUploader,this));
}
@borfee
Copy link

borfee commented Apr 20, 2011

no, this is do not. perhelps it is have right results, but it cann't upload image......
IE6 echo:
{"MediaResponse":{"Status":"success","MediaID":"49","Filename":"\u6d4b\u8bd5\u56fe\u7247.jpg","Filesize":7810,"FormatFilesize":"7.6K","ProgressKey":"1303297218703_UploadAttachment_1","PreviewImageLocation":"/uploads/FileUpload/scratch/fresh-25a43d73f8e3c3cd9ca0cf37874624ca-1303297230.3407.jpg","FinalImageLocation":"/uploads/FileUpload/9/49.jpg"},"FormSaved":true,"DeliveryType":"VIEW","Data":"","StatusMessage":"","RedirectUrl":""}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment