Not so much about publishing but ...

Asked about what industry I serve the answer is always "information industry". One of the aspects involved in this is programing, development of web applications and so on. In fact all of them are formatting, processing or distributing information.
I do a lot of my projects in Python and one thing that I've faced several times was the classic file upload.

Here it is the smallest snippet of Python code I use for that:

input type="file" name="selectedfile"
input type="submit" name="Submit" value="Upload"

upload_dir = "c:/"
fileitem = request.file('selectedfile')
name=fileitem.filename[string.rfind(fileitem.filename,'\\'):]
fout = file(str(upload_dir+name), 'wb')
while 1:
  chunk = fileitem.file.read(1000)
  if not chunk: break
fout.write (chunk)
fout.close()

I've looked over the web for something like that and all solutions looked like incomplete and not that direct.
Hope you will find it useful.

No comments: