On Wednesday, May 17, 2017 at 9:57:50 AM UTC-7, J-Michel Angers wrote:
>
> Hi,
> I'm building an app to fill "PurchaseRequest", to valid it by the staff, 
> and then type a "PurchaseOrder". Exactly like with a paper form that we 
> fill, and get signatures to valid it.
> Now the main boby of the app works (fill the form, set/choose the route, 
> send emails to the concerned persons (by request to the Active Directory), 
> ....
>
> Now I need for this app, to input one or more (or none) attached file 
> (quotation in PDF format, Excel file, technical data in PDF format)...
> I can upload this files, sort them, display the titles, ...
> Impossible to show the file.
> I see the file in the OS directories (<app>/upload/<file>, where <file> is 
> TPJ.Document.<.....>.extension).
> I have a customised html page, but either I get "unknown page", or I get 
> ... nothing. When I manually copy the link into explorer, I see the file 
> ....
> [...] 
>
And now the html view..
> <table><tr><td>
> {{=form.custom.begin}}
> <table border:5px;>
>     <tr><td colspan=5 align=center>
>         <h1>DEMANDE D'ACHAT    : {{=form.custom.dspval.id}}</h1>
>     </td></tr>
> ......
> </table>
> {{=form.custom.submit}}
> {{=form.custom.end}}
> </td>
>
> <td>
> <table><tr><td align=center><h2>Pièces jointes :</h2><br>
>     <ul>
>     {{for ligne in PiecesJointes:}}
>          <li>Avec A : {{=A(ligne.Titre, 
> _href=URL('upload',ligne.Document))}}<br>
>          Avec file:<a href=
> "file:\\{{=os.path.join(request.folder,'uploads',ligne.Document)}}">
> {{=ligne.Titre}}</a>
>          </li>
>          {{pass}}
>     </ul>
>     </td></tr>
> </table>
> </td></tr></table>
>
>
>
> With the "=A(ligne.Titre...", I see the link "
> http://127.0.0.1/da/upload/TPJ.Document.blabla.pdf. When I click I get 
> "404 unknown page"
> With the "<a href=file:\\...", I see the link 
> "file:///C:/Users/..../da/upload/TPJ.Document.blabla.pdf. When I click, 
> nothing arrive. When I copy manually the link, and paste into browser 
> addrress, my pdf file opens.
> I must have written something wrong... or I absolutly don't understand the 
> upload/download.
>
> Thank you for all informations :)
>
>
I think you would be well off to use the "download" function from the 
welcome app's default.py.  I use that in some apps (in one case, the URL is 
put into an email sent to the person-who-should-be-handling-the-file) with 
only minor modifications (the call procedure has an @auth.requires_login(), 
and the download function has some logging added).

Your URL would then be URL("download", args=ligne.Document) 
(The URL function will default the "app/controller" portion to "da/default/
").

Good luck!

/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 the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to