0

For my forum, I tried uploading a file with html using:

<form action="profiles.py" method="post">
<label class="labelOne" for="pics">Change your Profile pic </label>
<input type="file" name="uploadField" />

My python function takes that file, creates a file under userprofiles, and writes the data to it:

file = open('../data/accounts/userprofiles/'+str(form['name'].value)+'/'+'profilepics', 'w+')
file.write(str(form.getvalue('uploadField')))
file.close()

So, If I want burger.jpg to be my picture, I upload it, python takes that and creates a file with that name burger.jpg using w+ and then it writes the data to it(which should be the image).

However for some reason, I get no image.

What should I try next?

0

1 Answer 1

3

Set the enctype of your form to multipart/form-data

<form action="profiles.py" method="post" enctype="multipart/form-data">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.