I have already created ShadowUpload.asp and Upload.asp.
It works but, I want to display picture that was uploaded but I don't know how to display it
My source code is
<!-- #include file="ShadowUpload.asp" -->
<form action="<%=Request.ServerVariables( "Script_Name" )%>?action=1" enctype="multipart/form-data" method="POST">
Picture Profile: <input type="file" name="file1" value="<%=myPicture%>" /><br />
<button type="submit">Upload</button>
</form>
<img border="0" src="<%=myPicture%>" width="90" height="100">`
<%
Dim objUpload
If Request("action")="1" Then
Set objUpload=New ShadowUpload
If objUpload.GetError<>"" Then
Response.Write("sorry, could not upload: "&objUpload.GetError)
Else `
Response.Write("found "&objUpload.FileCount&" files...<br />")
For x=0 To objUpload.FileCount-1`
If (objUpload.File(x).ImageWidth>200) Or (objUpload.File(x).ImageHeight>200) Then
Response.Write("image to big, not saving!")
Else
Call objUpload.File(x).SaveToDisk(Server.MapPath("Uploads"), "")
Response.Write("file saved successfully!")
End If
Response.Write("<hr />")
Next
End If
End If
%>
You need to add the image for every file uploaded, and only if uploaded successfully:
If (objUpload.File(x).ImageWidth>200) Or (objUpload.File(x).ImageHeight>200) Then
Response.Write("image to big, not saving!")
Else
Call objUpload.File(x).SaveToDisk(Server.MapPath("Uploads"), "")
Response.Write("file saved successfully!")
Response.Write("<br /><img src=""Uploads/" & objUpload.File(x).FileName & """ height=""50"" />")
End If
This will show preview of the uploaded picture, with a set height of 50 pixels.
Related
I am trying to remove white spaces created after writing file in aspx page. Below is the code for your reference:
<div class="wrapper" runat="server">
<header class="main-header skin-blue">
<%If Session("UserRole") = "Admin" Or Session("UserRole") = "TeamLead" Then
Response.WriteFile("frmHeaderAdmin.aspx")
Else
Response.WriteFile("frmHeaderEmployee.aspx")
End If %>
</header>
<!-- Left side column. contains the logo and sidebar -->
<aside class="main-sidebar" runat="server">
<%If Session("Userrole") = "Admin" Then
Response.WriteFile("frmSideBarAdmin.aspx")
ElseIf Session("Userrole") = "TeamLead" Then
Response.WriteFile("frmSideBarTL.aspx")
Else
Response.WriteFile("frmSideBarUser.aspx")
End If%>
</aside>`enter code here`
</div>
Please let me know where I am going wrong so that I can make necessary changes in the code
I am working on Hr_Recruitment module.I have added a binary image field for HR->Application.I am trying to add functionality for external user to fill the job application them self through website.I have added name,email,phone,resume attachment fields in website for Job application.when they click on submit, it is updating in HR->Job Application Form.But Image field is not getting updated in Application.When opening the job application It is showing message like "Could not show the selected image".How to solve this issue?
controller/main.py
if post.get('image',False):
image = request.registry['ir.attachment']
name = post.get('image').filename
file = post.get('image')
attach = file.stream
file.show()
f = attach.getvalue()
webbrowser.open(image)
attachment_id = Attachments.create(request.cr, request.uid, {
'name': image,
'res_name': image,
'res_model': 'hr.applicant',
'res_id': applicant_id,
'datas': base64.decodestring(str(res[0])),
'datas_fname': post['image'].filename,
}, request.context)
views/templates.xml
<div t-attf-class="form-group">
<label class="col-md-3 col-sm-4 control-label" for="image">Image</label>
<div class="col-md-7 col-sm-8">
<img id="uploadPreview" style="width: 100px; height: 100px;" />
<input id="uploadImage" name="image" type="file" class="file" multiple="true" data-show-upload="true" data-show-caption="true" data-show-preview="true" onchange="PreviewImage();"/>
</div>
</div>
Add the image field as shown below in your XML template:
<img itemprop="image" style="margin-top: -53px; margin-left:19px; width:80px;" class="img img-responsive" t-att-src="website.image_url(partner, 'image', None if product_image_big else '300x300')"/>
<input class="input-file profileChooser" id="fileInput" type="file" name="ufile" onchange="validateProfileImg();"/>
remove the unnecessary attributes for you.
And in your controller function, you can get the value from the image fields as:
vals = {}
if post['ufile']:
vals.update({'image': base64.encodestring(post['ufile'].read())})
request.registry['res.partner'].write(cr, uid, [partner_id], vals)
The above code works for me, I have been using this to update partner images from ODOO website.
I am using odoo13 and I used this format to upload an image from the website to the respartner form view:
<div class="col-md-6">
<label for="image_1920" class="form-label">Passport Photo*</label>
<input type="file" class="form-control" id="image_1920" name="image_1920" required="1" />
</div>
import base64
#http.route('/registered', auth='public', methods=['GET', 'POST'], website=True)
def registration_submit(self, *args, **kw):
image = kw.get('image_1920', False)
kw.update({
'free_member': True,
'image_1920': base64.encodestring(image.read()) if image else False
})
member = request.env['res.partner'].sudo().create(kw)
I am loading a website into a WebBrowser in a winform. I wish to login using a log and pass automatically via vb.net
I have the following code executing once the page loads
WebBrowser1.Document.GetElementById("e").SetAttribute("value", "email#address")
WebBrowser1.Document.GetElementById("p").SetAttribute("value", "password")
WebBrowser1.Document.Forms(0).InvokeMember("submit")
I am able to fill in the boxes that need to contain the Log and pass but I am not able to fire off the login button of the webpage automatically. After research I am confident that I replicated the sample I found properly but obviously there is an issue. The 'button' isn't pressed because I don't get anything happening. When I press the website login manually it logs in correctly using the data that I filled in .
the webpage link is https://www.weatherzone.com.au/customise.jsp
and the relevant source data is below
<form action="/customise.jsp" method="post" style="width: 75%; text-align: left;">
<div style="margin-bottom: 1em;">
<label for="e">Enter your email address:</label>
<input style="width: 95%;" type="text" name="e" id="e" /><br />
</div>
<div style="margin-bottom: 1em;">
<label for="p">Enter your password:</label>
<input style="width: 95%;" type="password" name="p" id="p" /><br />
</div>
<div style="margin-bottom: 1em;">
<input type="checkbox" name="rmbr" id="rmbr" value="1" />
<label for="rmbr" style="display: inline;">Remember me (check this box if you are a regular user of this computer)</label>
</div>
<div style="text-align: right; margin-top: 20px; padding-top: 10px; border-top: 1px solid silver;">
<input class="submit btn" type="submit" name="target" value="login" />
</div>
<input type="hidden" name="dest" value="/" />
</form>
I applied this logic:
Put the code in a DocumentCompleted event to run the code after the document completed.
The DocumentCompleted also raises when an iframe document completed, so to get rid of iframes use a criteria like comparing e.Url with the base url know.
Find the submit button by name and click on it.
And it worked properly. It redirected to the same url and showed a red not authenticated message.
Code:
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If (e.Url.ToString().StartsWith("https://www.weatherzone.com.au")) Then
WebBrowser1.Document.GetElementById("e").SetAttribute("value", "email#address.com")
WebBrowser1.Document.GetElementById("p").SetAttribute("value", "password")
WebBrowser1.Document.All().GetElementsByName("target").Cast(Of HtmlElement).First().InvokeMember("click")
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.WebBrowser1.Navigate("https://www.weatherzone.com.au/customise.jsp")
End Sub
To make the code more stable, add required null checkings.
In my form design element, say "form1", for some reason, I need to disable its original form behavior and implement another form. So I used </form> at the beginning of the "form1" marked with pass-thru. And then I put some pass-thru http lines like below under </form>:
<form name="simple" method="post" enctype="multipart/form-data" action="test?openagent">
<label for="username">Your Name</label>
<input type="text" name="username" /><br />
<label for="email">Your Email</label>
<input type="text" name="email" /><br />
<label for="fileuploader">attachment</label>
<input type="file" name="fileuploader" />
<input type="submit" value="Sign Up!" />
</form>
The codes in agent "test" were mainly as below:
Dim s As New NotesSession
Dim doc As NotesDocument
Set doc = s.Documentcontext
If doc.Hasitem("REQUEST_CONTENT") Then
MsgBox "REQUEST_CONTENT=" & doc.REQUEST_CONTENT(0)
Else
If doc.Hasitem("REQUEST_CONTENT_000") Then
MsgBox "REQUEST_CONTENT_000=" & doc.REQUEST_CONTENT_000(0)
End If
End If
ForAll i In doc.Items
MsgBox i.name & "=" & i.values(0)
End ForAll
After I filled the username, email, and picked an attachment, and then submitted the form, I found there was neither "REQUEST_CONTENT" nor "REQUEST_CONTENT_000" item shown; but there was CONTENT_LENGTH item shown and of value 130520.
My question is, in Domino 9.0.x, what item(s) contain(s) the post data?
None. Simple but sad:
Notes just allows natively via Notes inserted File Upload Controls.
Lotusscript has never been able to handle POSTed binaries.
You should use a Form to accomplish that.
im currently trying to grab an avatar from an html web source, probllem is theres several img sources and containers that have the same name, heres the current part i need
</div>
<div class="content no_margin">
<img src="http://www.gravatar.com/avatar/4787d9302360d807f3e6f94125f7754c?&d=mm&r=g&s=250" /><br />
<br />
<a class="link" href="http://sharefa.st/user/donkey">Uploads</a><br />
<a class="link" href="http://sharefa.st/user/donkey/favorites">Favorites</a><br />
</div>
</div>
<div id="content" class="left">
<div class="header">
Uploads
</div>
<div class="content no_margin">
<div class="profile_box">
<div class="profile_info">
Now the part i need to grab is:
<img src="http://www.gravatar.com/avatar/4787d9302360d807f3e6f94125f7754c?&d=mm&r=g&s=250" /><br />
this image, Any help and id be grateful!
try:
Dim wb As New WebBrowser
wb.Navigate("")
Do While wb.ReadyState <> WebBrowserReadyState.Complete
Application.DoEvents()
Loop
wb.DocumentText = HtmlString 'Your Html
For Each img As HtmlElement In wb.Document.GetElementsByTagName("img")
If InStr(img.GetAttribute("src"), "avatar") Then
MsgBox(img.GetAttribute("src"))
End If
Next
You appear to be attempting to parse HTML 'by hand'. Please don't.
http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhu-way.html
see this question for some alternatives How do you parse an HTML in vb.net
Use regular expression to find what you're looking for:
http://msdn.microsoft.com/en-us/library/twcw2f1c.aspx
The example code demonstrates pretty much your scenario.