Server : Apache System : Linux 122.228.205.92.host.secureserver.net 5.14.0-362.18.1.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jan 29 07:05:48 EST 2024 x86_64 User : ondostategov ( 1002) PHP Version : 8.1.33 Disable Function : NONE Directory : /home/ondostategov/.trash/sita_training.1/ |
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>jQuery File Upload Example</title>
</head>
<body>
<input type="file" id="fileUpload" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link href="https://unpkg.com/filepond@^4/dist/filepond.css" rel="stylesheet" />
<script src="https://unpkg.com/filepond@^4/dist/filepond.js"></script>
<script>
// Register the FilePond plugin
const inputElement = document.querySelector('#fileUpload');
const pond = FilePond.create(inputElement);
// Listen for file add
pond.on('addfile', (error, fileItem) => {
if (error) {
console.error('Error uploading file:', error);
return;
}
const file = fileItem.file;
// Read file as Base64
const reader = new FileReader();
reader.onload = function (e) {
const base64String = e.target.result;
console.log("Base64 Encoded File:", base64String);
// You can send this string to the server or use it as needed
};
reader.readAsDataURL(file);
});
</script>
</script>
</body>
</html>