upload bug fixed
This commit is contained in:
@@ -92,26 +92,6 @@ console.log('accountDetails',accountDetails)
|
||||
* Checks if the selected file exceeds the maximum file size limit and displays an alert if it does.
|
||||
* If the file is within the size limit, it reads the file using the FileReader API and sets the profile image state with the result.
|
||||
*/
|
||||
// const profileImgChangeHandler = (e) => {
|
||||
// const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
|
||||
|
||||
// const file = e.target.files[0];
|
||||
// if (file && file.size > MAX_FILE_SIZE) {
|
||||
// alert("File size exceeds the limit.");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (file) {
|
||||
// const imgReader = new FileReader();
|
||||
// imgReader.onload = () => {
|
||||
// const imageDataUrl = imgReader.result;
|
||||
|
||||
// // Set the profile image
|
||||
// setProfileImg(imageDataUrl);
|
||||
// };
|
||||
// imgReader.readAsDataURL(file);
|
||||
// }
|
||||
// };
|
||||
|
||||
const profileImgChangeHandler = (e) => {
|
||||
setUploadStatus({loading: false, status: false, message:''})
|
||||
@@ -139,14 +119,15 @@ console.log('accountDetails',accountDetails)
|
||||
if (e.target.value !== "") {
|
||||
const imgReader = new FileReader();
|
||||
imgReader.onload = (event) => {
|
||||
let base64Img = imgReader.result.split(",")[1];
|
||||
let reqData = { // PAYLOAD FOR API CALL
|
||||
family_uid: accountDetails?.family_uid,
|
||||
file_name: uploadedFile?.name,
|
||||
file_size: uploadedFile?.size,
|
||||
file_type: uploadedFile?.type?.split("/")[0]?.toLowerCase(),
|
||||
file_data: event?.target?.result,
|
||||
file_data: base64Img,
|
||||
msg_type: 'FILE',
|
||||
action: 111305
|
||||
action: 11305
|
||||
}
|
||||
setUploadStatus({loading: true, status: false, message:'Loading...'})
|
||||
apiCall.sendFiles(reqData).then(res=>{
|
||||
|
||||
Reference in New Issue
Block a user