/    Sign up×
Community /Pin to ProfileBookmark

File input generator.

Hello there!
I wrote the code below to creat multiple file inputs.
Well, it works perfectly, but the file upload does not work and I just want to know if the file fields generated by my function can be used to upload files normally. Because they’re not being uploaded correctly.

[CODE]
inputFilesNumber = 0;

function addRemoveFileInput(elementToBeWritenInId,amountOfFileInputsInputId,toAdd){

amountOfFileInputsInput = document.getElementById(amountOfFileInputsInputId);
elementToBeWritenIn = document.getElementById(elementToBeWritenInId);

if(toAdd){
inputFilesNumber++;
elementToBeWritenIn.innerHTML = elementToBeWritenIn.innerHTML+”<div id=div”+inputFilesNumber+”><input type=’file’ name=’fileInput”+inputFilesNumber+”‘ id=fileInputId”+inputFilesNumber+” ></div>”;
}else{
elementToBeWritenIn.removeChild(document.getElementById(“div”+inputFilesNumber));
inputFilesNumber–;
}
amountOfFileInputsInput.value = inputFilesNumber;
}[/CODE]

You can see this code – as well as an extension verifier function – working in the attached file. You may use it as you please.

[upl-file uuid=8aac5c0d-1f11-4d61-b6fc-3ff5a67247e4 size=1kB]AddRemoveFileInput.zip[/upl-file]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@GraniteauthorJun 24.2009 — Ok, as I had imagined, the problem wasn't with this script, but with the "uploader" PHP file.

Fixed now.
×

Success!

Help @Granite spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...