/    Sign up×
Community /Pin to ProfileBookmark

Please Help uploading multiple files

Hello,
I have this script below that will allow a user to upload multiple images. I need to have it add another text box each time it adds a new upload box. The new text box will be for the user to add a tag or description of the image.

How do I add a new text box and retrieve the text they enter with each image?

<!—–function AddMoreImages() {
if (!document.getElementById && !document.createElement)
return false;
var fileUploadarea = document.getElementById(“fileUploadarea”);
if (!fileUploadarea)
return false;
var newLine = document.createElement(“br”);
fileUploadarea.appendChild(newLine);
var newFile = document.createElement(“input”);
newFile.type = “file”;
newFile.setAttribute(“class”, “fileUpload”);

if (!AddMoreImages.lastAssignedId)
AddMoreImages.lastAssignedId = 100;
newFile.setAttribute(“id”, “FileUpload” + AddMoreImages.lastAssignedId);
newFile.setAttribute(“name”, “FileUpload” + AddMoreImages.lastAssignedId);
var div = document.createElement(“div”);
div.appendChild(newFile);
div.setAttribute(“id”, “div” + AddMoreImages.lastAssignedId);
fileUploadarea.appendChild(div);
AddMoreImages.lastAssignedId++;

}

—->

Thank You

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@rnd_meMar 18.2011 — one at a time sounds like a PITA, use the same file input to add all the images at once by adding the "multiple" attrib to the file input.
Copy linkTweet thisAlerts:
@WolfShadeMar 18.2011 — That wouldn't allow text for each to be entered.
Copy linkTweet thisAlerts:
@rnd_meMar 21.2011 — That wouldn't allow text for each to be entered.[/QUOTE]

why couldn't a text input be added for each input.files.X, just like it is for single-images?

it's a lot faster to not browse a folder box anymore than needed, especially on a slow moving computer.
×

Success!

Help @Pongo 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 6.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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