This is code for manual upload (it's work for me):
def upload():
import os
import shutil
uploadfolder=os.path.join(request.folder, 'uploads')
form = FORM(
"Upload file:",
INPUT(_type='file',_name='my_file', requires=IS_NOT_EMPTY()),
'Your name:',
INP
> what is difference between:
> if form.process().accepted:
> and
> if form.accepts(request,session):
no difference functionally, just different APIs.
> If I have two variables (var1 and var2)
> var1 = Object
> var2 = cStringIO.StrindO 0x1234
>
> Before your example I was stack with
> file.write(
Thanks Anthony, upload it's work
Now I have some questions:
Can I use form.formstyle = 'divs' on form created with SQLFORM.factory or
some other methods to get div tag instead table
what is difference between:
if form.process().accepted:
and
if form.accepts(request,session):
If I have two varia
Something like this:
def upload():
import os
uploadfolder=os.path.join(request.folder, 'uploads')
form = SQLFORM.factory(
Field('file', 'upload', uploadfolder=uploadfolder),
Field('new_name'))
if form.process().accepted:
os.rename(os.path.join(uploadfolder,
Can I get full example for upload function?
This is maybe simply but after one day I don'n have any success.
- - Miroslav Gojic - -
On Sat, Nov 19, 2011 at 19:24, Anthony wrote:
> Don't put the form.accepts inside the 'if request.vars' block -- it needs
> to run even on form creation (to gener
Don't put the form.accepts inside the 'if request.vars' block -- it needs
to run even on form creation (to generate the hidden formname and formkey
fields).
On Saturday, November 19, 2011 12:44:31 PM UTC-5, miroslavgojic wrote:
>
> Now I have in controller:
> def upload():
> form = FORM("Upl
Now I have in controller:
def upload():
form = FORM("Upload
file:",INPUT(_type='file',_name='myfile'),INPUT(_type='submit',_name='submit',_value='Submit'))
if request.vars:
if form.accepts(request,session):
my_file = request.vars.myfile.file
my_filename = req
You can tell if the function is being called with a form submission by
checking for request.vars:
if request.vars:
print 'this is a form submission'
On Saturday, November 19, 2011 12:06:40 PM UTC-5, miroslavgojic wrote:
>
> The error is caused when file is not selected.
> By default on first
The error is caused when file is not selected.
By default on first run form is empty (file is not selected), and form
must wait for selecting and submitting.
How access to file before calling form? What that mean?
Miroslav
On Nov 19, 5:52 pm, Anthony wrote:
> You might need to access the file b
You might need to access the file before calling form.accepts (first you'll
have to check that form.vars.myfile exists). You can also access it via
request.vars.myfile (which won't change, even after form.accepts).
Anthony
On Saturday, November 19, 2011 11:41:02 AM UTC-5, miroslavgojic wrote:
>
> No need for 'form_data'. When you upload the file, the field values are
> stored in request.vars and then transferred into form.vars. The file upload
> will be in form.vars.myfile, which will already be a cgi.FieldStorage()
> object. So, form.vars.myfile.file will be the open file object, and
> f
On Saturday, November 19, 2011 4:54:03 AM UTC-5, miroslavgojic wrote:
>
> What I have for now:
>
> in view:
> {{=form}}
> {{=form_data}}
>
No need for 'form_data' on the page (your controller doesn't return it
anyway).
> in controller:
> import cgi
>
> def upload():
> form = FORM("Upload
>
Sure, you can code all that manually.
On Saturday, November 19, 2011 2:53:13 AM UTC-5, miroslavgojic wrote:
>
> I reed all in online book about upload and forms...
>
> Can I make my upload manually, something like: brows_file ->
> upload_to_some_folder.
> What is happening after I submit button 'u
What I have for now:
in view:
{{=form}}
{{=form_data}}
in controller:
import cgi
def upload():
form = FORM("Upload
file:",INPUT(_type='file',_name='myfile'),INPUT(_type='submit',_name='submit',_value='Submit'))
if form.accepts(request,session):
response.flash = 'form accepted'
Hear is PHP example (to show what is my wish to do):
in HTML:
Filename:
in PHP file upload_file.php:
0)
{
echo "Error: " . $_FILES["file"]["error"] . "";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "";
echo "Type: " . $_FILES["file"]["type"] . "";
echo "Size: "
I reed all in online book about upload and forms...
Can I make my upload manually, something like: brows_file ->
upload_to_some_folder.
What is happening after I submit button 'upload' - can I have control
on this activity.
I'm new with Web2Py and Python, but on PHP this is no problem, I make
all
On Friday, November 18, 2011 5:55:59 PM UTC-5, miroslavgojic wrote:
>
> some questions:
>
> Can I turnoff default changing name with upload function?
>
I don't think so. As an alternative, process the form with dbio=False so it
doesn't do the upload or database insert, and then manually process
some questions:
Can I turnoff default changing name with upload function?
Can I before upload start, change file name (rename(from.first.name,
to.second.name)) and than proceed to upload...
User select file for upload, application first give new name to file
and than start upload with new name,
What I need to do? It is hard to explain but I will tray.
On my faculty I need to setup small web for professors and students.
Professors can upload files (*.pdf, and possibly some *.zip) and they
need to login for putting content - uploading files.
Filter is make like SELECT(OPTION(),OPTION()), a
web2py renames the file for security purposes, and to enable it to retrieve
the file later via response.download. It encodes the original filename
within the new filename and decodes it upon download. What exactly do you
need to do?
Anthony
On Friday, November 18, 2011 3:03:48 PM UTC-5, mirosl
20 matches
Mail list logo