Jump to:

23456 Posts in 18905 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » xmlhttprequest to form field action not working in frontend

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

Page: 1
Go to End
Author Topic: 597 Views
  • SheaDawson
    Avatar
    Community Member
    45 Posts

    xmlhttprequest to form field action not working in frontend Link to this post

    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

  • Marcus
    Avatar
    Administrator
    86 Posts

    Re: xmlhttprequest to form field action not working in frontend Link to this post

    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?

  • SheaDawson
    Avatar
    Community Member
    45 Posts

    Re: xmlhttprequest to form field action not working in frontend Link to this post

    /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

  • Marcus
    Avatar
    Administrator
    86 Posts

    Re: xmlhttprequest to form field action not working in frontend Link to this post

    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?

  • SheaDawson
    Avatar
    Community Member
    45 Posts

    Re: xmlhttprequest to form field action not working in frontend Link to this post

    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

    597 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.