Tom Rider
Tom Rider

Reputation: 2805

How to upload a file to server?

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

Answers (3)

Thariama
Thariama

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

muthu
muthu

Reputation: 5461

You can not do because of security reasons

Upvotes: 1

Stan
Stan

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

Related Questions