Привет, помогите пожалуйста, такая вот проблема есть.
Код из страницы
<script type="text/javascript">
function duplicateHTML(copy,paste,baseid)
{
if(document.getElementById(copy))
{
e107_dupCounter++;
var type = document.getElementById(copy).nodeName; // get the tag name of the source copy.
var but = document.createElement('input');
var br = document.createElement('br');
but.type = 'button';
but.value = 'x';
but.className = 'button';
but.onclick = function(){ this.parentNode.parentNode.removeChild(this.parentNode); };
var destination = document.getElementById(paste);
var source = document.getElementById(copy).cloneNode(true);
var newentry = document.createElement(type);
newentry.appendChild(source);
newentry.value='';
newentry.appendChild(but);
newentry.appendChild(br);
if(baseid)
{
newid = baseid+e107_dupCounter;
newentry.innerHTML = newentry.innerHTML.replace(new RegExp(baseid, 'g'), newid);
newentry.id=newid;
}
destination.appendChild(newentry);
}
}
function doLoad(value)
{
var req = new JsHttpRequest();
req.onreadystatechange = function()
{
if (req.readyState == 4)
{
getID('result_upload').innerHTML += req.responseJS.q;
hideload_image();
}
}
req.open('POST', 'upload_images.php', true);
req.send({action:'upload_image', q:value});
showload_image();
}
</script>
<div id='up_container'><span id='upline'>
<input type="file" name="upl[]" id="up">
</span>
<br />
</div>
<input type="button" class="admin_button" value="Добавить картинку" onClick="duplicateHTML('upline','up_container');" /> <div id="ajax_button"><input type="button" class="admin_button" value="Загрузить" onClick="doLoad(this.form.upl)"></div>
Кнопка - добавить картинку, клонирует файловые поля. Я понял, что раз в имени поля стоит [], то имена полей в итоге будут выглядеть так: upl[0], upl[1], upl[2]. Собственно так и есть, то есть можно подсчитать кол-во пришедших полей через пхп так: count($_FILES).
Но вот задачто в том, что эта загрузка фоновая, через аякс. И вот как тут в ява скритпе сосчитать, кол-во отправляемых файлов (полей), и отправить это всё пхп скрипту в функции doLoad. req.send({action:'upload_image', q:value}); - это для переменной, а как туда все поля поместить.... проблема.
