By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,742 Members | 773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,742 IT Pros & Developers. It's quick & easy.

Upload multiple files with a single file element

P: 69
Hi,

I'm using the code at http://the-stickman.com/web-developm...-file-element/ to upload multiple files with a single file element. It works fine but for each file uploaded I want to store the contents of a text file which describes the file.

I've tried to understand the code but I'm not a Javascript nor XML guru. Would anyone be kind enough to look at the code and tell me where I'm going wrong.

I have the following:

Expand|Select|Wrap|Line Numbers
  1. var new_row_description = document.createElement( 'input' );
  2. new_row_description.type = 'text';
  3. new_row_description.value = document.getElementById( 'title' ).value;
  4. new_row_description.size = 60;
  5. new_row_description.name = "desc_" + element.name;
  6.  
but I can't get the value when I submit the form. Totally lost and in need of help.

Thanks, Sean
Aug 27 '07 #1
Share this Question
Share on Google+
10 Replies


pbmods
Expert 5K+
P: 5,821
Heya, Sean.

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Aug 28 '07 #2

P: 69
Hiya,

Currently it creates a div section where the name of each file upload in turn is displayed and it also creates a name/id for the file element of file_0, file_1 etc so that each file name can be accessed in a server side script such as PHP. Want I want to extend to it is to be able to store for each file that is uploaded a textual description. The code for how it uploads the files is given at: http://the-stickman.com/web-developm...-file-element/

Thanks,

Sean

Heya, Sean.

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Aug 28 '07 #3

acoder
Expert Mod 15k+
P: 16,027
You need to append this to the form/body. You've created it, but left it hanging in outer space. Use appendChild.
Aug 28 '07 #4

P: 69
Hi,

Apologies I left that bit out. What I have in full is:

Expand|Select|Wrap|Line Numbers
  1. var new_row = document.createElement( 'div' );
  2. var new_row_description = document.createElement( 'input' );
  3. new_row_description.type = 'text';
  4. new_row_description.value = document.getElementById( 'title' ).value;
  5. new_row_description.size = 60;
  6. new_row_description.id = "desc_" + element.name;
  7. new_row.appendChild( new_row_description );     
  8. // Add it to the list
  9. this.list_target.appendChild( new_row );
  10.  
Expand|Select|Wrap|Line Numbers
  1. list_target
is the id of the file element
Expand|Select|Wrap|Line Numbers
  1. <input id="my_file_element" type="file" name="file_1" >
. I'm still not getting
Expand|Select|Wrap|Line Numbers
  1. desc_file_0, desc_file_1 etc
only
Expand|Select|Wrap|Line Numbers
  1. file_0, file_1 etc
.

Thanks,

Sean
Aug 28 '07 #5

acoder
Expert Mod 15k+
P: 16,027
You can't append an input text field to another input element. Append it to the form or the body.
Aug 29 '07 #6

P: 2
Hi, i'm desperately trying to get hold of the code at ... http://the-stickman.com/web-developm...-file-element/ . However the link is broken, can you maybe post the code ? Thanks
Feb 11 '08 #7

acoder
Expert Mod 15k+
P: 16,027
Welcome to TSDN!
Hi, i'm desperately trying to get hold of the code at ... http://the-stickman.com/web-developm...-file-element/ . However the link is broken, can you maybe post the code ? Thanks
Are you sure? The link still works, I think.
Feb 11 '08 #8

P: 2
Thanks - its a great site.

No luck with the link i'm afraid. I've trying from other sites that reference the same url. Any chance you can help?
Feb 11 '08 #9

acoder
Expert Mod 15k+
P: 16,027
Thanks - its a great site.

No luck with the link i'm afraid. I've trying from other sites that reference the same url. Any chance you can help?
Here's the download link. It works.
Feb 11 '08 #10

ronverdonk
Expert 2.5K+
P: 4,258
Try the download link directly:
download link

Ronald
Feb 11 '08 #11

Post your reply

Sign in to post your reply or Sign up for a free account.