title: reactjs component for uploading csv file to server is not working properly
body: <p>I am learning <code>reactjs</code> for building web application. Basically, my goal is I want to create <code>reactjs</code> component that can upload local <code>csv</code> file to the server (I created server js). To do so, I come across a basic <code>reactjs</code> component implementation down below:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import React, { Component } from 'react';
  import logo from './logo.svg';
  import './App.css';
  
  class App extends Component {
    var FormBox = React.createClass({
      getInitialState: function () {
        return {
          file: '',
          FilePreviewUrl: ''
        };
      },
      pressButton: function () {
        e.preventDefault();
        console.log('handle uploading-', this.state.file);
      },
      uploadCSV: function (e) {
        e.preventDefault();
        let reader = new FileReader();
        let file = e.target.files[0];
  
        reader.onloadend = () =&gt; {
          this.setState({
            file: file,
            FilePreviewUrl: reader.result
          });
        }
        reader.readAsDataURL(file);
      },
      render: function () {
        let {FilePreviewUrl} = this.state;
        let FilePreview = null;
        if (FilePreviewUrl) {
          FilePreview = (&lt;img src={FilePreviewUrl} /&gt;);
        } else {
          FilePreview = (&lt;div className="previewText"&gt;Please select an Json for Preview&lt;/div&gt;);
        }
        return (
          &lt;div&gt;
          &lt;form action='.' enctype="multipart/form-data"&gt;
            &lt;input type='file'  onChange={this.uploadCSV}/&gt;
            &lt;button onClick={this.pressButton}&gt; Get it &lt;/button&gt;
          &lt;/form&gt;
          &lt;div className="filePreview"&gt;
            {FilePreview}
          &lt;/div&gt;
          &lt;/div&gt;
        )
      }
    })
  }
  ReactDOM.render(&lt;FormBox /&gt;, document.getElementById('root'))
  export default App;</code></pre>
  </div>
  </div>
  </p>
  
  <p>but when I run my component I got an error which is not intuitive to me. Here is the error:</p>
  
  <pre><code>Failed to compile.
  
  ./src/App.js
    Line 6:  Parsing error: Unexpected token
  
    4 | 
    5 | class App extends Component {
  &gt; 6 |   var FormBox = React.createClass({
      |       ^
    7 |     getInitialState: function () {
    8 |       return {
    9 |         file: '',
  </code></pre>
  
  <p>How to fix this error? How to make above implementation works for the purpose of uploading csv file to the server? any idea?</p>
  
  <p><strong>clarification</strong>:</p>
  
  <p>I am doing this because I intend to upload local csv file to the server and trigger API key that provided at back-end to populate the csv data to the database. I am newbie to reactjs so my above code may not be well shaped. can anyone help me how to make this works? any help would be appreciated.</p>
  
  <p><strong>goal</strong>:</p>
  
  <p>Sine few smart people in <code>SO</code> community suggested me that I was wrong about the implementation. What I am actually trying to do is to upload local files to server. How can I modify above code for creating <code>reactjs</code> component for uploading file to server? </p>