Every time I use plupload
to upload a file using the code below, I notice in the Firebug console that there is a message in red indicating POST /uploads 200 OK 8192ms. Upon further inspection of the terminal output, I see Completed 200 OK in 7653ms.
var uploader = new plupload.Uploader({
runtimes: 'gears,html5,flash,silverlight,browserplus',
browse_button: 'pickfiles',
autostart : true,
max_file_size: '10mb',
url: '/uploads',
resize: { width: 320, height: 240, quality: 90 },
flash_swf_url: '/Scripts/pl/plupload.flash.swf',
silverlight_xap_url: '/Scripts/pl/plupload.silverlight.xap',
filters: [
{ title: "Image files", extensions: "jpg,gif,png" },
{ title: "Zip files", extensions: "zip" }
]
});
uploader.bind('Init', function (up, params) {
$('#filelist')[0].innerHTML = "<div>Current runtime: " + params.runtime + "</div>";
});
uploader.bind('Error', function (up, err) {
$('#filelist').append("<div>Error: " + err.code +
", Message: " + err.message +
(err.file ? ", File: " + err.file.name : "") +
"</div>"
);
});
uploader.bind('FilesAdded', function (up, files) {
for (var i in files) {
$('#filelist')[0].innerHTML += '<div id="' + files[i].id + '">' + files[i].name + ' (' + plupload.formatSize(files[i].size) + ') <b></b></div>';
}
//uploader.start();
});
$('#uploadfiles').click(function (e) {
uploader.start();
e.preventDefault();
});
uploader.bind('UploadProgress', function (up, file) {
$('#' + file.id)[0].getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
});
uploader.init();
In the Uploads controller, the create action looks like this:
def create
@upload = Upload.new(:upload => params[:file])
if @upload.save
head 200
#redirect_to '/users'
else
render :action => "new"
end
end
I'm trying to figure out how to redirect to another page after finishing an upload. Even though I attempted to redirect to the users page in the create action with head 200
, nothing happens.
If anyone could provide guidance on how to achieve this redirection after an upload completes, I would greatly appreciate it. I've searched online but haven't found a solution yet...
Lastly, why does the Firebug console always show POST /uploads 200 OK without any accompanying log message after uploading a file?