locked
input type="file" upload RRS feed

  • Question

  • User1899743143 posted


    I have an application that needs to upload . I do not know how to make the C# side

        <script type="text/javascript" src="assets/js/core/libraries/jquery.min.js"></script>
        <script src="http://ajax.aspnetcdn.com/ajax/signalr/jquery.signalr-2.2.0.min.js"></script>
        <script src="http://localhost:52037/signalr/hubs"></script>
    
        <form enctype="multipart/form-data">
            <input type="file" id="foto_usuario" multiple />
        </form>
    
        <script type="text/javascript">
    
            $(function () {
    
                $.connection.hub.url = "http://localhost:52037/signalr";
                wsUpload = $.connection.wsUpload;
    
                wsUpload.client.foto_usuario = function (path) {
                    alert(path);
                };
    
                $.connection.hub.start(function () {
    
                    $('#foto_usuario').change(function () {
    
                        var files = $(this).get(0).files;
                        if (files.length > 0) {
    
                            var data = new FormData();
                            for (i = 0; i < files.length; i++) {
                                data.append("foto_usuario[" + i + "]", files[i]);
                            }
    
                        }
    
                        wsUpload.server.foto_usuario(files).fail(function (error) { debugger; });
    
                    });
    
                });
    
            });
    
        </script>


    Thursday, June 23, 2016 7:07 PM

Answers