Topic: Original file name remains after attempts to rename file in script
In reference to the following topics already on other plupload forums, I am trying to change the name of a file prior to uploading it. The name of the file is reflected in the widget, but the file name comes across as the original name when submitted.
Help w/file renaming
http://www.plupload.com/punbb/viewtopic.php?id=1008
Can I change file name of uploaded files on the client side?
http://www.plupload.com/punbb/viewtopic.php?id=644
This is my code:
<script type="text/javascript">
$(document).ready(function () {
$(function () {
$("#uploader").pluploadQueue({
runtimes: 'flash,silverlight,html5,gears,browserplus',
url: '/Home/Index',
max_file_size: '10mb',
unique_names: true,
rename: true,
resize: { width: 320, height: 330, quality: 90 },
filters: [
{ title: "Uploadable files", extensions: "jpeg,jpg,gif,png,zip,pdf,txt,rtf,doc,docx,xls,xlsx,csv" }
],
flash_swf_url: '/Assets/plupload/plupload.flash.swf',
silverlight_xap_url: '/Assets/plupload/plupload.silverlight.xap',
init: {
FilesAdded: function (objUploader, arrFiles) {
if (arrFiles.length > 0) {
$.each(arrFiles, function (i, file) {
file.name = "RENAME_" + file.name;
});
}
//objUploader.refresh();
},
UploadFile: function (objUploader, file) {
//file.name = "RENAME_" + file.name;
},
BeforeUpload: function (objUploader, file) {
//file.name = "RENAME_" + file.name;
}
}
});
$('form').submit(function (e) {
var uploader = $('#uploader').pluploadQueue();
// Validate number of uploaded files
if (uploader.total.uploaded == 0) {
// Files in queue upload them first
if (uploader.files.length > 0) {
// When all files are uploaded submit form
uploader.bind('UploadProgress', function () {
if (uploader.total.uploaded == uploader.files.length)
$('form').submit();
});
uploader.start();
} else
alert('You must at least upload one file.');
e.preventDefault();
}
});
});
});
</script>
What am I missing?