Reputation: 162
I need your help, I have some table, and i need to know if is possible to get the name and extension and put that in the input below of the each input type="file", this is because I need insert that name into a MySQL, and later make links with that names with their respective files.
Check the fiddle
Many thanks, hope you can help me.
Upvotes: 0
Views: 653
Reputation: 885
You can get full name of file, I'm not really sure that you need all this, but that's your deal.
So you can add an id for your input like this
<td colspan='2'>
<input id="Attached1" name="Attached1" type="text" />
</td>
Add data attribute on file input
<td colspan='2'>
<input type="file" name='archivo[]' data-input="#Attached1"/>
</td>
Then this script will do that you want to
$("input").on('change', function() {
$($(this).data("input")).val(this.files[0].name);
});
Demo HERE
Upvotes: 1
Reputation: 156524
You won't be able to do this from client-side javascript. When the form is submitted, you can capture the header information that is sent by the browser to the server in the "filename"
header.
Upvotes: 0