0

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

This is my code:

craft()->on('assets.saveAsset', function (Event $event) {

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

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

     //at the end:

     craft()->request->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!

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.