Export file attachment to actual filesystem
Hello, I've tried numerous ways to try to export a file attachment to a temp directory in the actual filesystem, but have failed to do so. Does anyone know a way to do this? I can export the file to the zope file system, but I would like to export it to an actual directory outside of zope (e.g. /home/user/files/). Thanks for anyone who has insight on this. html page: <FORM ACTION="mypage" METHOD="POST" ENCTYPE="multipart/form-data"> <INPUT TYPE="file" NAME="attach" VALUE=""> python code: import string import re import time form=context.REQUEST.form REQUEST=context.REQUEST if (form['attach'].filename != ''): mimename = form['attach'].filename mimearray = mimename.split(".") if (len(mimearray) > 1): mimetype = mimearray[-1] else: mimetype = "txt" filename = "f" + str(ad_id) + "." + mimetype new_id = "old_" + str(ad_id) content_type=form['attach'].headers['Content-Type'] if content_type.find('image') != -1: #.find() is a method in Python2.0< if hasattr(context.upload, filename): context.upload.manage_delObjects(filename) context.upload.manage_addImage(filename, form['attach'], filename) else: context.upload.manage_addImage(filename, form['attach'], filename) else: if hasattr(context.upload, filename): context.upload.manage_delObjects(filename) context.upload.manage_addFile(filename, form['attach'], filename) else: context.upload.manage_addFile(filename, form['attach'], filename) --Daniel
Daniel Tang wrote at 2003-5-12 11:11 -0400:
I've tried numerous ways to try to export a file attachment to a temp directory in the actual filesystem, but have failed to do so. Does anyone know a way to do this?
Maybe, "ExtFile" helps you. It saves the file in the file system (and keeps meta data in the ZODB). "LocalFS" might, too. When nothing helps, you can use an External Method and use Python's file manipulation facilities (--> Python library reference) to store the file in the file system. Be careful: there are security risks. Dieter
participants (2)
-
Daniel Tang -
Dieter Maurer