Search
 
SCRIPT & CODE EXAMPLE
 

HTML

js html input type image base64 example

 <input type="file" id="files" ref="files" v-on:change="handleFilesUpload($event)" class="form-control" accept="image/*" autofocus required/>


<script>
// import Swal from 'sweetalert2'
export default {
  middleware: 'isAdmin',
  data() {
    return {
      files: '',
      success: false,
      name: '',
      url: '',
      answers: {
        answer1: '',
        answer2: '',
        answer3: '',
        answer4: ''
      },
      money: '',
      rating: '',
      status: '',
      status_id: '',
      time: ''
    }
  },
  mounted() {
    this.getStatus()
  },
  methods: {
    async getStatus() {
      const data = await this.$axios.$get(`auth/getStatus`);
      this.status = data.data
      this.success = true
    },
    submitFiles(e) {
      e.preventDefault();
      let formData = new FormData();
      let file = this.files[0];
      formData.append('files', file);
      formData.append('name', this.name);
      formData.append('answers', JSON.stringify(this.answers));
      formData.append('money', this.money);
      formData.append('rating', this.rating);
      formData.append('time', this.time);
      formData.append('status_id', this.status_id);
      this.$axios.post('auth/imageQuestionCreate',
        formData,
        {
          headers: {
            'Content-Type': 'multipart/form-data'
          }
        }).then((res) => {
        this.$router.push(`/admin/question/view/${res.data.data.id}`)
      }).catch((error) => {
        console.log(error)
        console.log('FAILURE!!');
      })
    },
    handleFilesUpload(e) {
      this.files = this.$refs.files.files;
      const file = e.target.files[0];
      this.url = URL.createObjectURL(file);
    }
  }
}
</script>
Comment

PREVIOUS NEXT
Code Example
Html :: input and select box combined 
Html :: best html coding software 
Html :: html link tag for other website 
Html :: html enctype 
Html :: thymeleaf table for each 
Html :: safari input type number problem with decimals 
Html :: html input datetime-local value 
Html :: laravel hide html tags 
Html :: fa facebook icon 
Html :: use v-model in custom component 
Html :: times hmrl 
Html :: favicon react render 
Html :: bluetooth headphones cutting out 
Html :: how to fix navbar in bootstrap 
Html :: html radio only one checked 
Html :: button float right 
Html :: bootstrap dropdown going off page 
Html :: html select box 
Html :: html add vertical space below 
Html :: HTML5 Details & Summary 
Html :: bootstrap modal remove gray background 
Html :: circlular waiting icon bootstrap 
Html :: dropdown content left 
Html :: html table span 2 rows 
Html :: html a 
Html :: how to code hello world in html 
Html :: colspan 1.5 
Html :: underline text in html 
Html :: jquery ajax add loading 
Html :: resetting canvas html 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =