Semantic-Org / Semantic-UI

Semantic is a UI component framework based around useful principles from natural language.
http://www.semantic-ui.com
MIT License
51.12k stars 4.94k forks source link

[Form] Add File Input Styles #403

Open alihalabyah opened 10 years ago

alihalabyah commented 10 years ago

It would be nice if the file input styled and has some effects.

brigand commented 10 years ago

Usually file inputs are styled by styling a <label>, and hiding the <input>. I recommend something like this:

<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>
jlukic commented 10 years ago

Agreed about input type file, have some idea for this and drop zone for file drag&drop

patie commented 10 years ago

:+1:

Anachron commented 10 years ago

So, how's it going with this? Should be easy to implement as module, right?

nickevin commented 10 years ago

Thank you, brigand.

I write something like this(http://jsfiddle.net/nickevin/a4sD4/), YES, i copy your code.

2014-02-27_110239

<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.
    }
});
FrancisMengx commented 10 years ago

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.

ranga-nathan commented 10 years ago

Any expected date for this feature. We are using at many places and only those are looking different.

Anachron commented 10 years ago

Maybe take a look at this one, it's pretty good: http://plugins.krajee.com/file-input/demo

liorocks commented 9 years ago

The issue is still opened, any ideas about adding this feature?

mikemix commented 9 years ago

+

tiborsaas commented 9 years ago

The Bootstrap demo page is very nice. This would indeed be a nice addition to this library.

cspeer commented 9 years ago

+1

sos0 commented 9 years ago

+1

nyaaao commented 9 years ago

+1

francodgstn commented 9 years ago

+1

GeoffreyBooth commented 9 years ago

There’s a Meteor package for file uploads that claims its file upload control is styled for Semantic UI: https://github.com/tomitrescak/meteor-uploads

Perhaps the control from this package can be decoupled from Meteor and adapted for front-end use anywhere?

dmitrijs-balcers commented 9 years ago

+1

BenevidesLecontes commented 9 years ago

+1 waiting for this feature, i need so much.

NexPB commented 9 years ago

+1

hmaesta commented 9 years ago

+1

metasyn commented 9 years ago

+1

piya23300 commented 9 years ago

+1

listepo commented 9 years ago

+1

rumen-yankov commented 9 years ago

+1

Ethaan commented 9 years ago

+1

kodamirmo commented 9 years ago

+1

opvini commented 9 years ago

+1

jlukic commented 9 years ago

I guess this is pretty low hanging fruit.

dmitrijs-balcers commented 9 years ago

Good news!

metasyn commented 9 years ago

What did you all do in the mean time ?

Anachron commented 9 years ago

@metasyn Cough https://github.com/jlukic?tab=activity

whitefoxy commented 9 years ago

+1

metasyn commented 9 years ago

@Anachron I meant like what kind of form input styling did you do / use in the mean time? Not, what work as been done on semantic in the mean time

emil-nasso commented 9 years ago

+1

mattkenefick commented 9 years ago

+1

bhdrk commented 9 years ago

+1

jlukic commented 9 years ago

Discussed in #1703 as well

torayeff commented 9 years ago

+2

dolfly commented 9 years ago

+1

BlackDark commented 9 years ago

:+1:

louis-cl commented 9 years ago

+1

rufusthecat commented 9 years ago

+1

fixpunkt commented 9 years ago

+1

MohammedAl-Mahdawi commented 9 years ago

+1

joshjwalker commented 9 years ago

+1

mjnaderi commented 9 years ago

+1

caiotarifa commented 9 years ago

http://tympanus.net/Tutorials/CustomFileInputs/ Seems very nice! :smile:

jlukic commented 9 years ago

Thanks I'll keep those links in mind

listepo commented 9 years ago

@caiotarifa :+1:

mhingston commented 9 years ago

flow.js also looks like a good option.

Flow.js does not have any external dependencies other than the HTML5 File API. This is relied on for the ability to chunk files into smaller pieces. Currently, this means that support is limited to Firefox 4+, Chrome 11+, Safari 6+ and Internet Explorer 10+.

Edit: also, dropzone (see theming).