Reputation: 2805
I am using Upload File
control in MVC-3
project,
<input type="file" name="file" />
Is there any way Or is it possible to manually (programatically) assign the file to this input control? something like,
$('input[type=file]').val("filename or address or somethingelse" )
?
Upvotes: 3
Views: 292
Reputation: 50832
No, this is not possible due to security issues.
What you can do is to use some kind of uploader, i.e. http://valums.com/ajax-upload/
Upvotes: 1
Reputation: 26501
AFAIK you cannot select/assign a file via JS for security reasons. Otherwise you could enter website that automatically selects some sensitive data file from your PC and automatically upload it on server.
You can, however select file manually and upload it automatically via JS after selecting it.
Upvotes: 4