If you encounter the same issue, please follow the steps below:
Step 1: Implement the following method in your Controller for file upload and display
function manageUploads($file, $savepath, $gid = ""){
// code implementation for managing uploads
}
function displayFile($file_id){
// code implementation for displaying files
}
// other supporting functions related to file management
Step 2: Create the specified function in app.js
methods: {
getMedia: function (id) {
return window.location.origin + "/api/displayFile/" + id;
},
}
Step 3: Utilize the HTML video tag
<video width="1220" height="240" controls>
<source :src="$root.getMedia(videoUploadFile.id)" type="video/mp4">
Your browser does not support the video tag.
</video>
Step 4: Use the 'user_video' value to fetch the file and play the video
$candidate->user_video_file = $this->getFile($candidate->user_video);
Step 5: Assign the video file to the 'videoUploadFile' state in Vue.js
axios.get("/getCandidate").then((response) => {
if(response.data.candidate){
this.videoUploadFile = candidate.user_video_file;
}
});
Note: Ensure that the 'user_video' column is of integer type
Step 6: Upload a file and save it into the database as an integer value using the 'manageUpload' function declared in step 1
<input
ref="file"
type="file"
@change="handleFile('image')"
name="user_image"
accept="image/*"
id="cover-upload"
/>
// handleFile and addImage functions for processing file uploads
// PHP function for adding candidate profile image