Sunday, December 4, 2022
Subscribe to:
Post Comments (Atom)
Learn Web Technologies for Free. Learn C#, LINQ, ASP.NET MVC, .NET Core, jQuery, JavaScript, Angular, Node.js, HTTPS, Python, Sass, D3.js, and many more latest technologies using easy tutorials.
<
html
>
<
body
>
<
form
enctype
=
"multipart/form-data"
action
=
"python_upload.py"
method
=
"post"
>
<
p
>Upload File: <
input
type
=
"file"
name
=
"filenameupload"
/></
p
>
<
p
><
input
type
=
"submit"
value
=
"Upload"
/></
p
>
</
form
>
</
body
>
</
html
>
import
os
fileitem
=
form[
'filename_upload'
]
# check if the file has been uploaded
if
fileitem.filename_upload:
# strip the leading path from the file name
fn
=
os.path.basename(fileitem.filename_upload)
# open read and write the file into the server
open
(fn,
'wb'
).write(fileitem.
file
.read())
No comments:
Post a Comment