×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Dmitriy Lanets
Added: Jun 30, 2016 11:40 AM
Views: 1973
Tags: no tags
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>Laravel</title>
  5.  
  6.         <link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">
  7.  
  8.         <style>
  9.             html, body {
  10.                 height: 100%;
  11.             }
  12.  
  13.             body {
  14.                 margin: 0;
  15.                 padding: 0;
  16.                 width: 100%;
  17.                 display: table;
  18.                 font-weight: 100;
  19.                 font-family: 'Lato';
  20.             }
  21.  
  22.             .container {
  23.                 text-align: center;
  24.                 display: table-cell;
  25.                 vertical-align: middle;
  26.             }
  27.  
  28.             .content {
  29.                 text-align: center;
  30.                 display: inline-block;
  31.             }
  32.  
  33.             .title {
  34.                 font-size: 96px;
  35.             }
  36.         </style>
  37.         <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
  38.         <script>
  39.             function send(){
  40.             action  = "<?=action('UserController@uploadPhoto',['id'=>1]);?>";
  41.             $.ajax({
  42.                 url:    action,
  43.                 type:   'POST',
  44.                 timeout: 50000,
  45.                 data:   new FormData($('#upload-doc')[0]),
  46.                 cache:  false,
  47.                 dataType: 'json',
  48.                 processData: false,
  49.                 contentType: false,
  50. //                xhr: function() {  // custom xhr
  51. //                    myXhr = $.ajaxSettings.xhr();
  52. //                    if(myXhr.upload){ // if upload property exists
  53. //                        myXhr.upload.addEventListener('progress', progressHandlingFunction, false); // progressbar
  54. //                    }
  55. //                    return myXhr;
  56. //                },                
  57.                 success: function(data){
  58.                     alert('success');
  59.                 }
  60.             });
  61.         }
  62.         </script>  
  63.        
  64.     </head>
  65.     <body>
  66.         <div class="container">
  67.             <div class="content">
  68.                 <div class="title">FriendyPost</div>
  69.                
  70. {!! Form::open([ 'id'=>'upload-doc','files'=>true ]) !!}
  71.  
  72. {!! Form::file('fileupload', ['id'=>'fileupload', 'onchange'=>"this.parentNode.nextSibling.value = this.value" ], null) !!}Browse
  73. <button type="button" onclick="send();return false;" id="uploadFile">Upload</button>
  74. {!! Form::close() !!}
  75.  
  76.             </div>
  77.         </div>
  78.     </body>
  79. </html>
  80.