You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue exists on the 'Add Post' page in the form, specifically regarding image file uploads. When a user attempts to submit the form without selecting an image, an error is returned stating, 'The submitted data was not a file. Please check the encoding type on the form.'
Expected behavior:
The user should be able to submit the form even without an image. In this case, the backend should provide a placeholder image.
It was checked: The encoding type is correctly set in the Axios defaults.
The text was updated successfully, but these errors were encountered:
The current files list is empty, yet it is still being appended to the formData.
The bug was resolved by conditionally appending the image to the formData only if the user selected an image. In this case, the file list is not empty and can be successfully appended to the formData.
Updated code snippet:
if (imageInput.current.files.length > 0) {
formData.append("image", imageInput.current.files[0]);
}
The issue exists on the 'Add Post' page in the form, specifically regarding image file uploads. When a user attempts to submit the form without selecting an image, an error is returned stating, 'The submitted data was not a file. Please check the encoding type on the form.'
Expected behavior:
The user should be able to submit the form even without an image. In this case, the backend should provide a placeholder image.
It was checked: The encoding type is correctly set in the Axios defaults.
The text was updated successfully, but these errors were encountered: