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

Change Url Dynamically #71

Open
github5775 opened this issue Jul 13, 2018 · 3 comments
Open

Change Url Dynamically #71

github5775 opened this issue Jul 13, 2018 · 3 comments
Labels

Comments

@github5775
Copy link

Would like the ability to change options even after the .filedrop({}) has been called. For example, based on user input, I would like to change the Url that it uploads to, dynamically, many times while on the same page where it was initiated.

By changing the Url, I am able to change the parameters of the upload, i.e. additional parameters that tell the server function how to store the file.

If you would like, I can do a pull request, but I would appreciate a hint as to how to do this with your code. I was thinking of simply adding a .SetUrl() public function.

@ProgerXP
Copy link
Owner

Which options you want to change? You construct the URL yourself when uploading via iframe or sendTo so you don't have to change drop zone options for that.

@github5775
Copy link
Author

github5775 commented Jul 13, 2018 via email

@ProgerXP
Copy link
Owner

$(“#dropZone”).filedrop({ url: ‘https://www.abc.com/FileUpload?projectId=OldValue’, etc.});

You are doing it wrong. FileDrop has no option url - it has iframe.url option if that's what you want to set. However, review examples again: iframe is a fallback mechanism (which I really really hope is no more necessary nowadays). In normal cases, FileDrop won't trigger file submission - it will trigger the send event and you will call sendTo() on the passed File object. And sendTo() receives the URL. Therefore you don't have to change any options to change the URL.

If you are using iframe and want to change its url, then just change it: zone.opt.iframe.url = 'foo.php'

Or since you're using jQuery: $zone.filedrop('opt').iframe.url = ...

Also, it seems you are not using FileDrop correctly. As with any other jQuery plugin, you only initialize the control once. You don't need to call filedrop({options}) every time user interacts with the control, you just call it once on page load (or when target zone element is created). This would explain why you get erratic file dialog popups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants