Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made changes in fronted for uploading Signed-off-by: Paramjeet Kaur p… #5785

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/sections/Community/Web-based-from/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,31 @@ const WebBasedForm = () => {
};

const MemberFormStart = () => {
const [image, setImage] = useState(null);

const handleFileChange = (e) => {
const file = e.target.files[0];
if (file) {
const reader = new FileReader();
reader.onloadend = () => {
setImage(reader.result);
uploadFile(file);
};
reader.readAsDataURL(file);
}
};

const uploadFile = async (file) => {
const formData = new FormData();
formData.append('picture', file);

try {
const response = await axios.post('/upload', formData);
console.log('File uploaded successfully:', response.data);
} catch (error) {
console.error('Error uploading file:', error);
}
};
return (
<Container>
<h2 className="title">New Community Member</h2>
Expand Down Expand Up @@ -148,8 +172,9 @@ const WebBasedForm = () => {
XXL
</label>
</div>

<label htmlFor="picture" className="form-name">Picture</label>
<Field type="url" className="text-field" id="picture" name="picture" />
<Field type="file" className="text-field" id="picture" name="picture" onChange={(e) => handleFileChange(e)} />
<p className="para label">Please provide a link to your profile photo. Profile photos are used for <Link to="/community/members">community member profiles</Link> of longstanding community members.</p>
<Button secondary type="submit" className="btn" title="Next Step" /> <br /><br /><br /><br />
</Form>
Expand Down
Loading