Override <input type="file"> value property

It's possible to override value property in tag? My code in JavaScript

var element = document.createElement('input');
element.type = 'FILE';
element.__defineGetter__('value',function(){ return 'ololo'; });
alert(element.value);

It show empty string. Also I try override 'value' with prototype

function BPFILEINPUT(value)
{
    this.value = value;
}
BPFILEINPUT.prototype = element;
var myFileInput = new BPFILEINPUT('ololo');
alert(myFileInput.value);

It work, but crash on

form.appendChild(myFileInput);

I try pass test for upload form on 4shared.com

var uplElems = aUploadForm.elements;


   for (var i = 0; i < uplElems.length; i++) {
       var currentUploadElement = uplElems[i]
       if (currentUploadElement.type == 'file') {
           if (currentUploadElement.value == '') {
               // skip
           } else {
               if (!checkFileLength(currentUploadElement)) {
                  return false;
               }
               filesToUpload += getNumberOfSelectedFiles(currentUploadElement);
           }
       }
   }
   if (filesToUpload < 1) {
       alert('You didn\'t select any file to upload yet.');
       return false;
 }

UPDATE

I use UIWebView.

Answers


AFAIK, you can't set the value of <input type="file"> programmatically because of security reasons. A user has to explicitly click on it to set its value.


Need Your Help

Fetching json from MVC Controller

jquery asp.net-mvc knockout.js

I am trying to fetch some records from database in ASP.Net MVC and KnockoutJs.

How to get string type for nullable types

c# reflection

I'm generating a T4 template using the properties of my data class generated from my dbml files. To get the property type of the classes I use item.PropertyType.Name, the problem is that with nulla...