Witam,
zakladam nowy watek bo jeszcze takiego "problemu" nie bylo na forum. Zgodnie z wyszukanymi wskazowkami na tym forum zrobilem upload plikow z wykorzystaniem ajaxa. Uzylem tego kodu:
http://www.webtoolkit.info/ajax-file-upload.html
Teraz chcialbym tak zmodyfikowac kod JS by wywolanie funkcji AIM nie bylo na przycisku
onsubmit="return AIM.submit(this, {'onStart' : startCallback, 'onComplete' : completeCallback})
tylko na onchange='' w odpowiednim inpucie
<div><label>File:</label> <input type='hidden' name='MAX_FILE_SIZE' value='40000' />
<input type="file" name="pliczek" size='40'
onchange="AIM.submit(this, {'onStart' : startCallback, 'onComplete' : completeCallback})" /></div>
Nie znam sie za bardzo na javascripcie ale w ktoryms momencie on bierze wartosc z <form action='index.php'
to tez chcialbym zmienic na np ladowanie.php czy cos
KOD JS
AIM = {
frame : function© {
var n = 'f' + Math.floor(Math.random() * 99999);
var d = document.createElement('DIV');
d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+n+'" name="'+n+'" onload="AIM.loaded(\''+n+'\')"></iframe>';
document.body.appendChild(d);
var i = document.getElementById(n);
if (c && typeof(c.onComplete) == 'function') {
i.onComplete = c.onComplete;
}
return n;
},
form : function(f, name) {
f.setAttribute('target', name);
},
submit : function(f, c) {
AIM.form(f, AIM.frame©);
if (c && typeof(c.onStart) == 'function') {
return c.onStart();
} else {
return true;
}
},
loaded : function(id) {
var i = document.getElementById(id);
if (i.contentDocument) {
var d = i.contentDocument;
} else if (i.contentWindow) {
var d = i.contentWindow.document;
} else {
var d = window.frames[id].document;
}
if (d.location.href == "about:blank") {
return;
}
if (typeof(i.onComplete) == 'function') {
i.onComplete(d.body.innerHTML);
}
}
}