db = DAL('mysql://user:pass@myServer')
db.define_table('file',
Field('title', label=T('Title'), notnull=True),
Field('file', 'upload', uploadfolder=os.path.join(
request.folder,'static','uploaded_files'
), notnull=True, autodelete=True, label=T('File')),
format='%(title)s'
)
def files():
a_file = db.file(request.args(0))
crud.settings.update_deletable=False
if len(request.args) and a_file:
crud.settings.update_deletable = False
form = crud.update(db.file,a_file,next='files_list')
else:
form = crud.create(db.file)
return dict(a_file=a_file, form=form)
{{extend 'layout.html'}}
{{ if a_file: }}
<h1>{{=T('Edit file')}}</h1>
{{ else: }}
<h1>{{=T('Add a file')}}</h1>
{{ pass }}
{{=form}}
127.0.0.1.2013-03-16.11-43-07.109e09df-378c-4e89-96b1-175c300f70d6
web2py™ | (2, 4, 2, 'stable', datetime.datetime(2013, 3, 4, 3, 26, 21)) |
---|---|
Python | Python 2.7.2: C:\Python27\python.exe (prefix: C:\Python27) |
1. | Traceback (most recent call last): |
dest_file = open(pathfilename, 'wb')
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Massimo,
Still has this issue... :(
I am using 2.14.6 web2py running in windows7 with pydal 17.03 and python 2.7
I have this filename 54 characters (including '.pdf ')
This is the field on my db.py
After i add a record including an upload file this is the Error
Adding record including upload file
Need help on resolving this issue since i cannot control the filename length of the user will upload
Also i check the length newfilename length and including its path hope it helps
The error is directing to this file
I also tried changing my field with length value but still error upon adding files with upload
Thank you in advance,
Jak
Note that you do have some control over the length of the filename:
Note that my experience includes having the web2py folder in a path like
c:/users/mememe/web2py_win/web2py-2.14.6/web2py
That's a fair-sized headstart on total pathlength,
but so far I haven't had any users (any of me) produce a filename that caused a problem.
On a linux system where actual users upload files, the longest name (as stored) is 235 characters, and the path is 57 characters. The filename is actually generated by a non-web program that we control, and sent via libcurl. The name encodes some information relevant to the client. The 235 length is after web2py hashes the name used on the client.
/dps
/dps
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/ee6NBnj_TyU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.