Basically after the file upload, I would like to refresh/reload
"show_project_summary.html" to show the list of the file that just been
downloaded.
On Wednesday, January 13, 2016 at 1:49:42 PM UTC-5, Ron Chatterjee wrote:
>
> *I have this in my view (show_project_summary.html).*
>
>
>
> {{ if (submission.created_by == auth.user_id):}}
> <div id="file-uploader"></div>
> {{pass}}
>
>
>
>
>
> *Script in the same view at the bottom:*
>
> <script>
> jQuery(document).ready(function() {
> var uploader = new qq.FileUploader({
> // pass the dom node (ex. jQuery(selector)[0] for jQuery users)
> element: document.getElementById('file-uploader'),
> // path to server-side upload script
> action:
> '{{=URL("upload_callback_submission")}}/{{=request.args(0)}}',
> sizeLimit: 150000000,
> minSizeLimit: 0,
> allowedExtensions: ['xls','jpg', 'jpeg', 'pdf',
> 'txt','doc','docx','ppt', 'pptx', 'htm','html','xml','xmls',
> 'txt','ppt','png', 'gif'],
> // set to true to output server response to console
> debug: true,
>
> // events
> // you can return false to abort submit
> onSubmit: function(id, fileName){},
> onProgress: function(id, fileName, loaded, total){},
> onComplete: function(id, fileName, responseJSON){},
> onCancel: function(id, fileName){},
>
> messages: {
> // error messages, see qq.FileUploaderBasic for content
> typeError: "{file} {{=T('has invalid extension.')}}
> {{=T('Only')}} {extensions} {{=T('are allowed.')}}",
> sizeError: "{file} {{=T('is too large, maximum file size
> is')}} {sizeLimit}.",
> minSizeError: "{file} {{=T('is too small, minimum file size
> is')}} {minSizeLimit}.",
> emptyError: "{file} {{=T('is empty, please select files again
> without it.')}}",
> onLeave: "{{=T('The files are being uploaded, if you leave now
> the upload will be cancelled.')}}"
> },
> showMessage: function(message){ alert(message); }
> });
> });
> </script>
>
>
>
> *In my default controller:*
>
> def upload_callback():
> Selected_project = []
> #Rendering rule for Post
> Selected_project = db.Project(request.args(0, cast=int))
> db.Project_Files.Project_id.default = Selected_project.id;
> project = db.Project[request.args(0)]
> if Selected_project is None:
> raise HTTP(404)
> if 'qqfile' in request.vars:
> filename = request.vars.qqfile
> newfilename = db.Project_Files.filename.store(request.body,
> filename)
> db.Project_Files.insert(Project_id=Selected_project.id,
> filename=newfilename)
> return response.json({'success': 'true'})
>
>
>
>
>
>
> On Wednesday, January 13, 2016 at 1:43:10 PM UTC-5, Anthony wrote:
>>
>> Please show some code.
>>
>> On Wednesday, January 13, 2016 at 1:37:16 PM UTC-5, Ron Chatterjee wrote:
>>>
>>> How do I update a current page in its view after a file submission if
>>> the redirect doesn't work?
>>>
>>> {{redirect(URL('show_project_summary', args = Selected_project.id),
>>> client_side = True)}}
>>>
>>> Any response.js that will update or reload/refresh the current page?
>>>
>>>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.