Is there a way to include parameters from Javascript to be sent to a custom AsyncUploadHandler?
Such parameter could be a folder selected in the page.
I tried to change the url by setting the ctrl._handlerUrl attribute from various events. Does not work, the params are removed before they get to the handler.
Creating cookies might work but are no solution in my case.
I am wondering if I am the only person needing such a thing...? Please help!
Thanks,
Stephan
PS: There seems to be a bug when setting a handler url on server side with query string parameters. These parameters are then properly passed to the handler, however, the control adds a "?type=rau". It should of course have added "&type=rau".
9 Answers, 1 is accepted
Unfortunately including parameters from Javascript to a custom AsyncUploadHandler is not a supported scenario.
As for the behavior that you described it is a known issue and it is already logged for fixing.
Hope this will be helpful.
Plamen Zdravkov
the Telerik team
The file upload scenario is like this.
1. User enter a "entity" (client)
2. The file + the "entity ID" needs to get uploaded to the handler
3. The custom handler analyzes the file based on the file and "entity ID"
4. The custom handler sends the result back to the Web client using custom IAsyncUploadResult.
5. The Web Client picks up the custom IAsyncUploadResult and if more info is needed, ask the user for this.
7. Submit including validation
I was thinking of using a custom AsyncUploadConfiguration object and access it from the Web client side using the OnClientFileUploading event to set the "entity ID". Is it possible ?
Regards
Ole Oscar Johnsen
It is not possible to add or change parameters of the uploading file due to security restrictions. If you want to validate the files somehow please refer to this on-line demo.
You can also review our Custom Handler demo which shows how to save images directly to a database, without using temporary folder.
Hope this information will be helpful.
Plamen Zdravkov
the Telerik team
You have mention that there is a bug in adding parameters to the url and there also exist an old reply that says this
----------------------------------------------------
Posted on Feb 18, 2011 (permalink)
Hi alien9882,We are currently implementing passing custom parameters in the query string. I believe we will be able to present a solution for the upcoming Q1 release.
As for the configuration object not passing values to the handler, please, update to the latest possible version and try again. There used to be an issue with the custom configuration but we have resolved it. Does the issue persist after the upgrade?
Kind regards,
Genady Sergeev
the Telerik team
-------------------------------------------------------------
That is what I need. Add url parameters to the handler request.
If this is not possible/ not going to be fix very soon I need to find another async file upload solution.
We have been using Telerik for years, and it will be odd to use another supplier for async upload. (I don't know if they exist, but I need to start looking for that soon).
Kindly Regards
Ole Oscar Johnsen
It seems that I misunderstood your question in the beginning. Please excuse me for that. Passing parameters is currently supported in RadAsyncUpload only from the server side as it is shown in our on-line demo and in the attached project. At the moment such behavior can not be achieved from the client side. It seems that implementing this functionality was postponed due to other features with greater priority and interest from the clients. You can vote for this issue and observe its status in our Pits system -here. Please excuse us once again for this limitation of our control.
Hope this will explain the issue.
Plamen Zdravkov
the Telerik team
1. The event OnClientFileUploading can't be used to set parameters like cookies since it async and is called during the upload.
So I went back to only return the temporary file name + the standard info from the custom asyncupload handler.
Then I created a new generic handler that uses the info from asyncupload.
This one is called from the OnClientFileUploaded function in javascript using jQuery and I am done.
The new handler needs to know about the asyncupload temporary folder. I am not transferring that to the client.
Here is the javascript code
function FileUploaded(radAsyncUpload, eventArgs) {
//document.cookie = "ClientID=; expires=Thu, 01-Jan-70 00:00:01 GMT;";
//var state = radAsyncUpload.get_clientState();
var fileInfo = eventArgs.get_fileInfo();
var clientCombo = $find("<%= Client.ClientID %>");
var value = clientCombo.get_value();
CallFileRecognizer({ fileInfo: fileInfo.MetaData, fileName: fileInfo.FileName, clientId: value });
}
function FileRecognizerComplete(result) {
var fileTypeCombo = $find("<%= FileType.ClientID %>");
if (result != '') {
var item = fileTypeCombo.findItemByValue(result);
item.select();
} else {
fileTypeCombo.clearSelection();
}
}
function FileRecognizerFailed(result) {
alert(result.responseText);
}
function CallFileRecognizer(data) {
$.ajax({
url: '<%= FileRecognizerHandler %>',
contentType: "application/json; charset=utf-8",
data: data,
success: FileRecognizerComplete,
error: FileRecognizerFailed
});
return false;
}
Regards
Ole Oscar Johnsen
Thank you for sharing you workaround with the community and your concern with RadControls.
Plamen Zdravkov
the Telerik team
I am looking for this functionality as well and it seems it is still not available and, 5 years since this post, the bug with ?type=rau is STILL present. Is there any other way than the ajax example at the bottom to address this? I need to pass parameters from the client to the handler.
I am attaching a sample page where a similar scenario is implemented in a scenario where a file can be dragged to one of two folders.
Hope this will be helpful.
Regards,
Plamen
Telerik by Progress