Open github5775 opened 6 years ago
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.
So, what I would like to do is add a SetUrl(url) interface on the filedrop control, so that I can change the url at will from js without having to re-init the control, like $(“#dropZone”).SetUrl(‘https://www.abc.com/FileUpload?projectId=value5’). But maybe you have a better solution.
[cid:image002.png@01D41ACC.FC7CB9B0]
[cid:image001.png@01D41ACC.7C857A80]
Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10
From: Pavel notifications@github.com Sent: Friday, July 13, 2018 2:38:23 PM To: ProgerXP/FileDrop Cc: Michael Z; Author Subject: Re: [ProgerXP/FileDrop] Change Url Dynamically (#71)
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.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/ProgerXP/FileDrop/issues/71#issuecomment-404918205, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGwlr5PgfUE19U8V1wQET9vmdFKBYNbrks5uGOkfgaJpZM4VOW5R.
$(“#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.
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.