-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Form] Add File Input Styles #403
Comments
Usually file inputs are styled by styling a <div>
<label for="file" class="ui icon button">
<i class="file icon"></i>
Open File</label>
<input type="file" id="file" style="display:none">
</div> |
Agreed about input type file, have some idea for this and |
👍 |
So, how's it going with this? Should be easy to implement as module, right? |
Thank you, brigand. I write something like this(http://jsfiddle.net/nickevin/a4sD4/), YES, i copy your code. <div class="field">
<div class="ui action input">
<input type="text" id="_attachmentName">
<label for="attachmentName" class="ui icon button btn-file">
<i class="attachment basic icon"></i>
<input type="file" id="attachmentName" name="attachmentName" style="display: none">
</label>
</div>
</div> var fileExtentionRange = '.zip .rar .tar .pdf .doc .docx .xls .xlsx .ppt .pptx';
var MAX_SIZE = 30; // MB
$(document).on('change', '.btn-file :file', function() {
var input = $(this);
if (navigator.appVersion.indexOf("MSIE") != -1) { // IE
var label = input.val();
input.trigger('fileselect', [ 1, label, 0 ]);
} else {
var label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
var numFiles = input.get(0).files ? input.get(0).files.length : 1;
var size = input.get(0).files[0].size;
input.trigger('fileselect', [ numFiles, label, size ]);
}
});
$('.btn-file :file').on('fileselect', function(event, numFiles, label, size) {
$('#attachmentName').attr('name', 'attachmentName'); // allow upload.
var postfix = label.substr(label.lastIndexOf('.'));
if (fileExtentionRange.indexOf(postfix.toLowerCase()) > -1) {
if (size > 1024 * 1024 * MAX_SIZE ) {
alert('max size:<strong>' + MAX_SIZE + '</strong> MB.');
$('#attachmentName').removeAttr('name'); // cancel upload file.
} else {
$('#_attachmentName').val(label);
}
} else {
alert('file type:<br/> <strong>' + fileExtentionRange + '</strong>');
$('#attachmentName').removeAttr('name'); // cancel upload file.
}
}); |
I think you may want to make the first input disabled. Normally you don't want people do edit the file name when they are uploading. |
Any expected date for this feature. We are using at many places and only those are looking different. |
Maybe take a look at this one, it's pretty good: |
The issue is still opened, any ideas about adding this feature? |
|
The Bootstrap demo page is very nice. This would indeed be a nice addition to this library. |
+1 |
3 similar comments
+1 |
+1 |
+1 |
There’s a Meteor package for file uploads that claims its file upload control is styled for Semantic UI: Perhaps the control from this package can be decoupled from Meteor and adapted for front-end use anywhere? |
+1 |
+1 |
+1 |
2 similar comments
+1 |
+1 |
+1 |
1 similar comment
+1 |
@hmaesta no worries, nobody's demanding anything. Just poking a little fun at the age of this one and keeping it alive :) |
I hope these give you a little hint guys https://jsfiddle.net/09hp81dd/6/ |
@jafarpagerjaya but that has nothing to do with File Input Styles? Doh. |
@Anachron Yes, it does. Mouseover image and click the button. It is a good contribution, thank you @jafarpagerjaya. |
Oh wow, that's very hidden! Just a bit non-fitting to the rest of Semantic UI! |
Sorry if this is rude, but is this still headed to be added in the near future? |
For those using React: Seems to be less of a headache (and no jQuery) this way: quoting:
|
I'm using react-semantic-ui, and I had to do |
I am also looking for the same for using in angular.. |
I have worked around this issue this way: <div class="field six wide">
<label>File</label>
<div class="ui action input">
<input type="text" readonly>
<input type="file" name="File" style="display: none!important;" />
<div class="ui icon button">
<i class="cloud upload alternate icon"></i>
</div>
</div>
</div>
then in JS
$('input:text, .ui.button', '.ui.action.input').on('click', function (e) {
$('input:file', $(e.target).parents()).click();
});
$('input:file', '.ui.action.input').on('change', function (e) {
var name = e.target.files[0].name;
$('input:text', $(e.target).parent()).val(name);
}); |
thanks a lot. let me try this |
it's been 5 years... |
😞 |
+1 Using Semantic UI with React and really enjoying it. File uploads are an important feature and would love to have these styled like the rest of Semantic UI. |
+1 Semantic UI is a very beautiful framework and would definitely be even better having file uploads styled! |
im sorry im still confused with this |
Well it's been 6 years^^ |
@DennisLoska This project is currently in hiatus with all development taking place over at Fomantic UI |
@omairvaiyani Thanks for the info. They don't have a file uploader component yet, but at least the last comment was like two weeks ago fomantic/Fomantic-UI#105 |
It's now 2021, this issue was created on 2013... |
Then go & implement it yourself? |
It would be nice if the file input styled and has some effects.
The text was updated successfully, but these errors were encountered: