This is a migrated thread and some comments may be shown as answers.

[Solved] Programmatically upload selected files (not using the Upload button)

4 Answers 160 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Danny
Top achievements
Rank 1
Danny asked on 09 Dec 2011, 10:13 PM
Hi,

Is there a way to make the upload control to upload the selected files via javascript and not via the Upload Files button?

My upload control has the 'multiple' option set to FALSE. And I want to submit the selected files using a button I created, and not the Upload Files button that comes with the upload control.

<%= Html.Telerik().Upload()
      .Name("attachment")
      .Multiple(false)
      .Async(async => async.Save("Save", "Home"))
      .ClientEvents(e => e.OnUpload("onUpload").OnSuccess("onSuccess"))
%>

<!-- is it possible to make the upload control to upload the selected files with this button instead??? -->
<input type="button" onClick="upload();" />  



Thanks in advance,
Danny.

4 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 12 Dec 2011, 08:10 AM
Hello Danny,

No, selecting and uploading a file through JavaScript is not possible. Actually, most browsers will allow it, but IE won't. It's a feature.

I hope this helps.

Greetings,
Tsvetomir Tsonev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Danny
Top achievements
Rank 1
answered on 12 Dec 2011, 06:46 PM
Thanks Tsvetomir!

What I'm trying to accomplish sorta is to have the Telerik Upload Control in a grid, and make it update the selected files only when the onSave is applied to the row of the grid.

The upload control with .AutoUpload(true) will upload the files as soon as they get selected from the browsing.
The upload control with .AutoUpload(false) will present an upload button in IE, and no upload button for Firefox.

Is there a way to activate the upload from the Upload Control in the respective row, when the row gets edited?



Thanks again,

Danny.
0
T. Tsonev
Telerik team
answered on 13 Dec 2011, 09:09 AM
Hi Danny,

We don't provide a public method for initiating the upload. We'll address this in a feature release. For the moment you can use the following code:

$(".t-upload-selected", rowElement).click()

Here, rowElement is the table row that we want to search in.

Regards,
Tsvetomir Tsonev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Danny
Top achievements
Rank 1
answered on 14 Dec 2011, 12:07 AM
Works like a charm.


Thanks a lot Tsvetomir!!!


Regards,
Danny
Tags
Upload
Asked by
Danny
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Danny
Top achievements
Rank 1
Share this question
or