Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

xmlhttprequest to form field action not working in frontend


5 Posts   611 Views


27 September 2011 at 12:10pm Community Member, 46 Posts

Hey all

I'm creating an html5 drag/drop upload form field. When the file is dropped an xmlhttprequest is created and posts the file data to the form fields upload action link - /profile/EditProfileForm/field/Image/upload. I always get a 404 in response in the front end, but it works in the backend.... Is there something I have to do to get this to work in the front end? The upload function is public and I have defined it in the $allowed_actions array.

Thanks for any ideas


28 September 2011 at 11:25am Administrator, 86 Posts

Have you got a PHP debugger to trace through the request processing to see what it's failing on? Is /profile a custom page type, or a straight up controller?


28 September 2011 at 12:58pm Community Member, 46 Posts

/profile is a straight up controller.

What gets me is... When trying in the cms I can navigate directly to the upload action of the field, in my browser, with no problems- ie. /admin/EditForm/field/Artist/item/9/DetailForm/field/Image/upload?SecurityID=5094...

Here's a debug_request screenshot of the request in a the cms

And here's a debug_request screenshot with of the same in the front-end. There are some vague errors there but I'm not sure what to make of them

I don't have a PHP debugger... is there one you would recommend for this?

Thanks very much for your response :)


28 September 2011 at 7:47pm Administrator, 86 Posts

Try removing upload from the allowed_actions array... it looks like it's matching immediately on that as an action and trying to process it directly, instead of processing it through the form. Is the EditForm defined in the allowed_actions array?


28 September 2011 at 10:46pm Community Member, 46 Posts

Aah ok... tried removing upload from allowed_actions but still seeing the same problem. EditProfileForm is defined in the profile controllers allowed actions too. I'm almost thinking now I might just send the upload request to a normal standalone controller... Not ideal but it might have to do for now, been stuck on this for days!

Thanks again for your help =D