Hello together, I've a problem with upload a picture and the method cookId(id='', title='', file=file). This method doesn't work for me? The method cookId() doesn't give a id or a title back. Why? Whats wrong? Form -------------------------- <form action="addFile" method="post" enctype="multipart/form-data"> <input type="file" name="file"> <input type="submit" value="upload"> </form> Python (not pythonScript) -------------------------- def addFile(self, file): "This method adds a file" # create the file if(file): id, title = cookId(id='', title='', file=file) self.manage_addProduct['P01_DownloadFolder'].manage_addFile(id=id, title='', file=file) Second Way I tryed (the manage_addFile() call the cookId by standard. -------------------------- def addFile(self, file): "This method adds a file" # create the file self.manage_addProduct['P01_DownloadFolder'].manage_addFile(id='', title='', file=file) cookId is a method from Image.py -------------------------------- def cookId(id, title, file): """ it gets the id from a file """ if not id and hasattr(file,'filename'): filename=file.filename title=title or filename id=filename[max(string.rfind(filename, '/'), string.rfind(filename, '\\'), string.rfind(filename, ':'), )+1:] return id, title The error: ---------- The "id" is not defined cookId does not set the id, How can id get the id from the file in a different way. Is the Form enctype="multipart/form-data" wrong? What should i use? Thanks to all and have a nice week. Roger Ineichen ___________________________ END OF MESSAGE
Roger Ineichen writes:
I've a problem with upload a picture and the method cookId(id='', title='', file=file). This method doesn't work for me? The method cookId() doesn't give a id or a title back. Why? Whats wrong? Your file does not have a "filename" attribute.
This may happen when you either forgot the 'enctype="multipart/form-data"' or the 'method=post'. Dieter
participants (2)
-
Dieter Maurer -
Roger Ineichen