Reputation: 59
I have a Javascript code where it appends a blank file input into a table row and a clear button.
$('.imageFile').each( function() {
var $this = $(this);
var $imagefile = $("<input type='file' class='imageFileRow'>").attr('name',$this.attr('name')+"[]")
.attr('value',$this.val());
$image.append($imagefile);
var $imageclear = $('<input />')
.attr({
type: 'button',
name: 'imageClear',
class: 'imageClear',
value: 'Clear File'
});
$image.append($imageclear);
});
But what I want to know if it is possible is that if the user selects a file using the textbox above, it obviously stores the file link in that file input textbox, but I want it to store the file link in a hidden input I have in the form code below. Also if the user clicks on the 'Clear file' button, it clears the file not only in the file input textbox above but also in the hidden input as well.
Below is form code which contains the hidden input:
<form id="QandA" action="insertQuestion.php" method="post" >
<input type="hidden" class="imageFile" name="fileImage">
</form>
Upvotes: 0
Views: 131
Reputation: 8821
As far as I know you can't access that information; the sandbox will prevent that from happening (and I'm glad it does; it's none of your business that I store my document in C:\porn\girlfriend\hellokitty.jpg ;-) )
Also; you do realize that even if you could access that information the form would only post the file location and not the actual file?
Edit/update Check out this simple testcase
IE, Opera, Safari and Chrome return c:\fakepath\
+ <actual filename> and I'm sure other browsers will do the same.
Upvotes: 1