So many ways to do this but you can try this in JS fiddle and it works for
me (https://jsfiddle.net/k6mcvj3j/). You can then use the custom form
explained in web2py book and insert them in the database
<form name="contactform" class="contactform" method="post"
onsubmit="return validateForm()" action="your_action">
<label>Sender Email:</label>
<input type="text" id="semail" name="semail" />
<label>Recipient Email:</label>
<input type="text" id="remail" name="remail" value="" />
<label for="Subject">Subject:</label>
<input type="text" name="Subject" id="Subject" />
<label for="Attachment">Attachment:</label>
<input type="file" name="attach1" id="attach1" />
<label for="Message">Message:</label><br />
<textarea name="Message" rows="20" cols="20"
id="Message"></textarea>
<div class="submit-btn">
<input type="submit"/>
</div>
</form>
<style>
.contactform
{
font-family: Verdana, Arial, sans-serif;
width:550px;
}
.contactform label
{
float: left;
text-align: right;
margin-right: 15px;
width: 200px;
padding-top: 5px;
}
.contactform input{
width:300px;
padding: 5px;
font-family: Helvetica, sans-serif;
margin: 0px 0px 10px 0px;
border: 2px solid #ccc;
}
.contactform textarea {
vertical-align: bottom;
width: 310px;
height:150px;
color: #777;
}
.submit-btn input
{
width:50px;
float: left;
text-align: right;
margin-left: 480px;
padding-top: 5px;
}
</style>
ref: google search.
On Monday, June 12, 2017 at 9:03:05 PM UTC-4, Dave S wrote:
>
>
>
> On Saturday, June 10, 2017 at 5:56:19 AM UTC-7, Diego Tostes wrote:
>>
>> Hi,
>>
>> how can i send to a controller the attachment file from a html form in my
>> view?
>>
>> Rgds
>>
>> Diego
>>
>
> Not sure what you're after. If you're using web2py tools like SQLFORM to
> make a form that reflects a table you've defined in a model, than an field
> of type "upload" gets uploaded in a pretty automatic way when the submit
> button is clicked, and form.vars will include the made-safe filename; the
> default location for the file in in [myapp]/uploads. For an intro to this,
> see
> <URL:http://web2py.com/books/default/chapter/29/03/overview#An-image-blog>
> If you do it this, you get drag-and-drop already built-in.
>
> If you're handcrafting the form for a table defined in a model, you just
> need to get the right widget for the uploads. If you're handcrafting the
> form, and it's not for a table, then you will have to save the upload
> temporary file your front end provides (or turn a stream into a file,
> sometimes), but you should still have information in request.post.vars
> about it. For drag and drop, if you're using the web2py widget, I'm
> guessing that does the job for you, otherwise it is pretty painless in
> HTML5.
>
> One reference for the HTML5 route is
> <URL:
> http://www.htmlgoodies.com/html5/other/working-with-the-drag-and-drop-api-in-html5.html>
>
> If you don't think I've answered your question, try saying what you mean
> in a different way, or give more details about the task you're trying to
> accomplish.
>
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.