the getfile script lets us view server files on the clientbut in some senseit is generalpurpose file download tool although not as direct as fetching file by ftp or over raw socketsit serves similar purposes users of the script can either cut-and-paste the displayed code right off the web page or use their browser' view source option to view and cut as described earlierscripts that contact the script with urllib can also extract the file' text with python' html parser module but what about going the other way--uploading file from the client machine to the serverfor instancesuppose you are writing web-based email systemand you need way to allow users to upload mail attachments this is not an entirely hypothetical scenariowe will actually implement this idea in the next when we develop the pymailcgi webmail site as we saw in uploads are easy enough to accomplish with client-side script that uses python' ftp support module yet such solution doesn' really apply in the context of web browserwe can' usually ask all of our program' clients to start up python ftp script in another window to accomplish an upload moreoverthere is no simple way for the server-side script to request the upload explicitlyunless an ftp server happens to be running on the client machine (not at all the usual caseusers can email files separatelybut this can be inconvenientespecially for email attachments so is there no way to write web-based program that lets its users upload files to common serverin factthere isthough it has more to do with html than with python itself html tags also support type=file optionwhich produces an input fieldalong with button that pops up file-selection dialog the name of the clientside file to be uploaded can either be typed into the control or selected with the popup dialog to demonstratethe html file in example - defines page that allows any client-side file to be selected and uploaded to the server-side script named in the form' action option example - pp \internet\web\putfile html putfileupload page <form enctype="multipart/form-datamethod=post action="cgi-bin/putfile py"select client file to be uploaded view script code one constraint worth notingforms that use file type inputs should also specify multipart/form-data encoding type and the post submission methodas shown in this server-side scripting