Hi
I'm trying to work with the HTML5 FileAPI via a shim.
The shim when initiated on non-HTML5 browsers uses a flash fallback, and I can access the details in the normal FileAPI manner.
However, when a file is selected, the underlying input element is not populated with the file details, so the required input element is still blank and so the form won't submit.
How do I get the file name including full path so I can populate the input element with the file details so the form can then be submitted?
Looking at the FileAPI specs, I can't see this as an attribute or method to get file path?
Your help is appreciated.
1DMF
"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
I'm trying to work with the HTML5 FileAPI via a shim.
The shim when initiated on non-HTML5 browsers uses a flash fallback, and I can access the details in the normal FileAPI manner.
Code:
$('#fp_file').on('change',function() {
fileSelected( $(this) );
});
// File selected
function fileSelected(ele)
{
var file = $(ele).prop('files')[0];
var fileSize = 0;
if(file)
{
[b] // has input elememnt been populated?
// need to populate input element with selected file details?[/b]
if(file.size > 1024 * 1024)
{
fileSize = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() + 'MB';
}
else
{
fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB';
}
$('#fileName').html(file.name);
$('#fileSize').html(fileSize);
$('#fileType').html(file.type);
$('#file_dets').show('slide');
}
else
{
$(ele).val('');
$('#file_dets').hide('slide');
}
}
However, when a file is selected, the underlying input element is not populated with the file details, so the required input element is still blank and so the form won't submit.
How do I get the file name including full path so I can populate the input element with the file details so the form can then be submitted?
Looking at the FileAPI specs, I can't see this as an attribute or method to get file path?
Your help is appreciated.
1DMF
"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music