Ciao a tutti,
ho la seguente funzione per aggiungere un campo dinamico di tipo file in un form:
function add() {
if (document.createElement && document.getElementById && document.getElementsByTagName) {
var divLabel = document.createElement("div")
divLabel.setAttribute("class","label");
divLabel.setAttribute("id","allegato"+files);
var inputField = document.createElement("input");
inputField.setAttribute("type","file");
inputField.setAttribute("name","allegato" + files);
inputField.style.width="305px";
inputField.style.border="1px solid #000";
inputField.style.fontSize="8pt";
inputField.style.fontFamily="Verdana, Arial, Sans-serif";
divLabel.appendChild(inputField);
document.getElementById('allegati').appendChild(di vLabel);
files++;
}
}
A prima vista funziona tutto, ma non appena faccio il submit e visualizzo l'array $_POST (php) non mi trova questi campi...come mai?
Il tutto è dovuto al tipo dell'oggetto, xkè se sostituisco file con text allora me lo trova.
Grazie.![]()