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


Reply


5 Posts   633 Views

Avatar
SheaDawson

Community Member, 46 Posts

27 September 2011 at 12:10pm

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

Avatar
Marcus

Administrator, 86 Posts

28 September 2011 at 11:25am

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?

Avatar
SheaDawson

Community Member, 46 Posts

28 September 2011 at 12:58pm

/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 http://i.imgur.com/9lPBx.png

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 http://i.imgur.com/vv9jh.jpg

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

Thanks very much for your response :)

Avatar
Marcus

Administrator, 86 Posts

28 September 2011 at 7:47pm

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?

Avatar
SheaDawson

Community Member, 46 Posts

28 September 2011 at 10:46pm

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