Python
  Home arrow Python arrow Page 6 - Python on the Web
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PYTHON

Python on the Web
By: Mark Lee Smith
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 27
    2004-05-18

    Table of Contents:
  • Python on the Web
  • Creating a Warning
  • Cookies
  • Sending Email
  • A Last Example
  • Inside uploads()...

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Python on the Web - Inside uploads()...
    (Page 6 of 6 )

    We first need to make sure that the field 'name' provided is in our 'form'. As long as it is then we get the path (as it appeared in the file field) of the file we want to upload and get the files name using os.path.basename(). We then join it to the 'path' using the os.path.join() function... this lets us to upload files to different places and keep the original filename.

    Next we loop over the available file types in 'args' and check the files extension against each type. If the file is a valid type, then we make sure the file doesn't already exists (files won't be uploaded if the file exists to prevent overwriting) before writing the file to the server.

    As in the limits() example uploads() can be used with an if statement to check if the function was successful or not. Or even use it with limits() so the user can only upload a set number of files per day.

    Ok, by now you should have a fair idea of what exactly writing web applications with python is about and why you would want to, as well as have some idea of what's possible... but this is only the tip of the iceberg!

    Hope you've had fun. If you want to learn more about Python or the subjects covered here, then start clicking:

    http://www.python.org - Python homepage
    http://www.python.org/doc/2.3.3/tut/tut.html - Python tutorial
    http://www.python.org/doc/2.3.3 - Python Documentation online!
    http://www.apache.org - Apache homepage
    http://httpd.apache.org/docs - Apache Documentation
    http://www.modpython.org - mod_python homepage!
    http://www.zope.org - Zope homepage!
    http://spyce.sourceforge.net - Spyce [Python Server Pages] homepage!

    Note: All the sample programs shown and discussed in this article were tested on Windows XP running Python 2.3 under Apache 1.3. Upload script was tested on remote Linux server.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

       

    PYTHON ARTICLES

    - SSH with Twisted
    - Mobile Programming in Python using PyS60: UI...
    - Python: Count on It
    - Python Strings: Spinning Yarns
    - Python: More Fun with Strings
    - Python: Stringing You Along
    - Python Operators
    - Bluetooth Programming in Python: Network Pro...
    - Python Sets
    - Python Conditionals, Lists, Dictionaries, an...
    - Python: Input and Variables
    - Introduction to Python Programming
    - Mobile Programming in Python using PyS60: Ge...
    - Bluetooth Programming using Python
    - Finishing the PyMailGUI Client: User Help To...

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway