Redirect after saveAsset in plugin I'm trying to redirect at the end of the saveasset function in init().

This is my code:

craft()-&gt;on('assets.saveAsset', function (Event $event) {

     // a lot of code here ##########################

     //#############################################

     //at the end:

     craft()-&gt;request-&gt;redirect('myurl.com'); 
}


When I save an asset with the redirect function at the end I get the following alert:

Upload failed for filename.csv.

The upload works when I leave the redirect out.

Thanks!
You could try to use a task, to make sure the upload is completed before redirecting.

Here is a good starting point on how to use a task:
Documentation on creating tasks

Basically you define the steps of a task, in you case I guess 2. The next step of a task is started when the last step returned true.