Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url doesnt support GET-params (fix inside) #34

Closed
Deefjuh opened this issue Dec 9, 2013 · 1 comment
Closed

url doesnt support GET-params (fix inside) #34

Deefjuh opened this issue Dec 9, 2013 · 1 comment

Comments

@Deefjuh
Copy link

Deefjuh commented Dec 9, 2013

When initialising the uploader, the url does not support GET-parameters like so:

uploader = new ss.SimpleUpload({
      button: 'UploadButton', // HTML element used as upload button
      url: 'myfilepage.php?action=mydispatcher', // URL of server-side upload handler
      name: 'uploadfile' // Parameter name of the uploaded file
    });

The reason is that in the method _uploadXhr the queryURL always adds a '?' between the settings.url and ss.obj2string( params );.
Because the obj2string takes place on the fly, you also can't 'hack' the name param on init becuase it will treat the whole string as a the get-param i.e.:
name: 'myparam=test&uploadfile'

The fix is easy, albeit a bit crude:

    // Build query string
   queryURL = settings.url + ((settings.url.match(/\?.*/gi))?'&':'?')  + ss.obj2string( params );

Didn't bother to do a pull-request, as you guys might want to tweak the regexp.

@LPology
Copy link
Owner

LPology commented Dec 10, 2013

Thanks for bringing this up. This is a good catch, I've never had to add GET params to the URL, so it's never crossed my mind before. Let me try this out and do some testing, but it's definitely something that will be added to the plugin.

Thanks again for pointing this out.

@LPology LPology closed this as completed Dec 30, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants