Reputation: 9
Here is my db Model
db.define_table('manage_music_file',
Field('action_is', requires=IS_IN_SET(('Insert',
'Remove')),notnull=True, default='Insert'),
Field('wav_file', 'upload', comment='Please upload your .wav
file',requires=IS_NOT_EMPTY()
)
This my controller
def index():
form = SQLFORM(db.manage_music_file)
#return dict(form=form)
if form.process().accepted:
logger.debug(('here we ahve a form',form))
errors = []
if form.vars['action_is'] == 'Insert':
logger.debug(('where file need to place'))
if not form.vars['wav_file']:
errors.append('No file given')
return 'No file given'
else:
dirname='/var/lib/asterisk/sounds/musiconhold'
logger.debug(('where file need to place', dirname))
import os.path
completeName = os.path.join(dirname, form.vars.wav_file)
file1 = open(completeName, "a")
file1.close()
return dict(form=form)
I am sending wav file A.wav in upload But i am receiving file in this format in directory
manage_music_file.wav_file.a70701e297ffec7a.412e776176.wav
I want same name A.wav in directory as well
A.wav
Upvotes: 0
Views: 409
Reputation: 5285
Hamza, web2py renames these files as a security measure, to help prevent directory traversal attacks.
Upvotes: 1