
May 19th, 2004, 11:42 AM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
Heres a very basic upload script staight form my head that should work, although untested. If you want to accept image uploads then you will need to write the file out using the wb flag but the basics are there. You might also want to check that the file doesnt already exist, this way you dont loose anything from a file conflict.
Code:
#!/usr/bin/env python
import cgi, os
form = cgi.FieldStorage()
if 'upload' in form:
name = os.path.split(form['upload'].filename)
file(name[-1], 'w').write(form['upload'].value)
Mark.
__________________
programming language development: www.netytan.com – Hula
|