1<script>
2async function uploadFile() {
3 let formData = new FormData();
4 formData.append("file", fileupload.files[0]);
5 await fetch('/upload.php', {
6 method: "POST",
7 body: formData
8 });
9 alert('The file has been uploaded successfully.');
10}
11</script>
1<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
2<form>
3 <label for="file-upload" class="custom-file-upload">
4 <i class="fa fa-cloud-upload"></i> Upload Image
5 </label>
6 <input id="file-upload" name='upload_cont_img' type="file" style="display:none;">
7</form>
1.custom-file-upload {
2 border: 1px solid #ccc;
3 display: inline-block;
4 padding: 6px 12px;
5 cursor: pointer;
6}
1<input id='fileid' type='file' hidden/>
2<input id='buttonid' type='button' value='Upload MB' />
1<input id="fileupload" type="file" name="fileupload" />
2<button id="upload-button" onclick="uploadFile()"> Upload </button>
1<?php
2
3/* Get the name of the uploaded file */
4$filename = $_FILES['file']['name'];
5
6/* Choose where to save the uploaded file */
7$location = "upload/".$filename;
8
9/* Save the uploaded file to the local filesystem */
10if ( move_uploaded_file($_FILES['file']['tmp_name'], $location) ) {
11 echo 'Success';
12} else {
13 echo 'Failure';
14}
15
16?>