I am using Lazarus I have an app with webbrowser component on it that logs into a website loads a page as below (see html code below), and fills in different inputs. The last input is a file to upload. I would like my app to "click" Browse, select a file i want to, and Open. After that I could do a post the form OR just upload the file and carry on.
1
I have the following html code on the site:
<td align="left" class="RequiredInput">File:</td>
<td class="datafield">
<form name="frmMain" id="frmMain" action="upload.asp?step=2&output=1" method="post" enctype="multipart/form-data">
<input type="file" name="filename" id="filename">
</form>
I tried executing JS from my app : document.getElementById('filename').value = 'C:\x.csv'
2
I tried using the following code HttpPostFile from synapse:
uFileName := 'C:\x.csv';
uStream := TFileStream.Create(uFileName, fmOpenRead);
uList:=TStringList.Create;
if HttpPostFile('upload.asp?step=2&output=1', 'filename', uFileName, uStream, uList) then
ShowMessage('OK');
It did nothing at all (I followed the activity of the app with Fiddler)
This is a known problem, and there is a solution, but you're going to have to convert it from ะก# to Delphi.
Another possible solution is to upload the file using URL Moniker APIs. The upload will then happen on the same session the WebBrowser control is already using. There is an MSKB article:
How To Handle POST Requests in a Pluggable Protocol Handler
The POSTMON.EXE sample linked to the article has disappeared from Microsoft website, but still can be found here.
Related
I'm working With Alfresco Community Edition.
Here's the code I've tried so far: Alfresco-Smalgyax.
I have created an All-in-One Project, to add a new page to the create.. menu. My Page Loads just fine.
I followed, the Adding a menu item to the "Create..." menu in DocLib tutorial, before adding a custom form field and JavaScript to the newly added share page.
I've added a custom field to upload a file to cm:content.
I've added some Javascript to get and set the cm:name and mimetype once an Upload file is chosen.
All the Metadata is correctly ingested. However, the file is not.
Previously I was successfully, able to upload a file with custom data by following the documentation: Processing multipart forms. However, that created a whole new Service endpoint and a custom page that didn't inherit the same look/feel as the rest of the web-application.
The page under create.. has the same look/feel as the rest of the site. But Upload Fails, Is there a way to leverage the Look/feel of the site and upload a file with metadata and set a custom type in Alfresco?
Clarification
The cm:content field has been customized like so:
<field id="cm:content" label-id="" mandatory="true">
<constraint-handlers>
<constraint type="MANDATORY" event="input"
validation-handler="Smalgyax.forms.validation.setNameValue" />
</constraint-handlers>
<control template="/file.ftl">
<control-param name="editorAppearance">explorer</control-param>
</control>
</field>
file.ftl sets the form input element like so:
<input id="${fieldHtmlId}" type="file"
name="${field.name}"
<#if field.disabled>disabled="true"</#if> />
additionally, file.ftl adds custom JavaScript to the page, because I was unable to get it successfully loaded as a separate file using
<forms>
<dependencies>
<js src="/set-name-field.js"/>
</dependencies>
<!-- form definition here -->
As the Alfresco documentation clearly suggests it won't supports the upload feature. The field type shows cm:content that won't accept a file to accept a file even though you have customized and added a explorer option in the code. That is the reason file is not and only content is uploading.
https://docs.alfresco.com/community/tasks/dev-extensions-share-tutorials-add-menuitem-create-menu.html
<field id="cm:content" label-id="">
<control>
<control-param name="editorAppearance">explorer</control-param>
</control>
</field>
For upload a file , you should use the html component like below,
<input type="file" multiple="" name="files[]" class="dnd-file-selection-button">
and the javascript should be same as the file-upload.js and dnd-upload.js.
http://localhost:8180/share/res/components/upload/file-upload.js
http://localhost:8180/share/res/components/upload/dnd-upload.js
Please refer the link below to upload a file through a ajax call.
https://hub.alfresco.com/t5/alfresco-content-services-forum/how-to-upload-a-file-from-a-custom-share-page/td-p/32361
I am trying to upload a file. It uploads fine, but while uploading it shows all file. I want to restrict to only selected files like pdf,jpg and jpeg files.
I need to while uploading a file when a browser window open that time only these files are visible remaining file should be hide. So that user is not able to select wrong file.
Can anyone tell me how can I do this?
I am using Vaadin 7.5.1 and Upload component and a Receiver.
The current Vaadin Upload component does not support this. There's an enhancement request for it which would be dead easy for Vaadin Inc (or a contributor) to implement now that all the major browsers support this functionality.
Here's the technical explanation: The Vaadin Upload component creates HTML like this:
<input type="file" name="foo">
but what you would have liked it to produce would be something like this:
<input type="file" name="foo" accept=".pdf,.jpg,.jpeg">
Here's how the above HTML will look in Firefox:
Basically the accept attribute will tell the browser to open a file selection dialog with a certain filter.
Note that this is a client-side thing. It doesn't prevent a savvy end user from uploading something that doesn't match your filter to your server. That goes for any kind of filtering done on the client-side no matter how it is done. For this reason you'll still need some server-side validation as well.
Piece of cake with JavaScript - you just have to check into the HTML source of page where that button/browse field is placed to find actuall class name of generated html element - this is example for .csv, Vaadin generates class name titled "gwt-FileUpload", so you have to set it like this to see only .csv files after clicking on "Import" button:
upload.setButtonCaption("Import");
JavaScript.getCurrent().execute("document.getElementsByClassName('gwt-FileUpload')[0].setAttribute('accept', '.csv')");
Add this dependency to your pom file
<dependency>
<groupId>com.wcs.wcslib</groupId>
<artifactId>wcslib-vaadin-widget-multifileupload</artifactId>
<version>1.10</version>
</dependency>
And use the following code to upload files, set filter using setAcceptFilter method:
UploadStateWindow uploadStateWindow = new UploadStateWindow();
uploadStateWindow.setOverallProgressVisible(true);
MultiFileUpload fileUpload = new MultiFileUpload(uploadFinishedHandler,
uploadStateWindow, true);
fileUpload.setAcceptFilter(".png,.jpg");
fileUpload.setImmediate(true);
fileUpload.getSmartUpload().setUploadButtonCaptions("upload", "upload");
i need to set on my web page a upload form for videos and i want that this videos are sent to my mail.
i found this code
<form name="myWebForm" action="mailto:annie.etoile#gmail.com" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="10mb" />
<input type="video" name="uploadField" />
<input type="submit" value="Send">
</form>
But when i press on "Send" it opens my mailing software, it doesn't send autmatically to me the video.
Maybe there's something wrong in the code?
It "opens your mail software" because that's exactly what it's being told to do here:
action="mailto:annie.etoile#gmail.com"
When you say you want it to "upload"... Where do you want it to go? If you want to send it to the web server then you need some server-side resource which can receive it. For example, if you have a PHP page which accepts the file upload, you'd change your form action to that page:
action="fileupload.php"
Then you'd have server-side code in that PHP file to accept the uploaded file and do whatever you want to do with it. (Including mail it to you.)
It doesn't have to be PHP on the server-side code, any server-side language/framework/environment/etc. can do the job. The point is that you'd need something there. If all you have is client-side code (which is all you have in the question) then the mailto: action is about as good as it's going to get.
I am trying to send an email from the partner window using the Send Mail menu on the right hand panel.
For this I have created a template email from the configuration menu, left the body (Text) empty and filled the body (Rich/html) with:
<p>Some text in <b>bold</b></p>
When I run send mail from the partner form, the message body is desperately empty and it looks like it is defaulting the message body to the Body (Text) tab from the email template.
This is confirmed when I look at table email_template where the field subtype is always "Plain".
I tried to setup the Action window specific to my email template by setting the domain value to [('subtype','=','html')], but it doesn't change anything. I also added this code to most of the Action window domains that relate to email but it hasn't changed anything either.
Does anyone know how to default sending email in HTML format from OpenERP?
UPDATE: Has anyone got a sample of HTML code that works for them, meaning they receive correctly in their email client?
My issue is that if I leave the Plain Text empty within the template and have some html tags under the Rich/html, then I receive an email in format html, but it is always empty. Even the source is totally empty. I suppose there is something wrong with my html syntax. Maybe I need to double the "/" in a closing paragraph as it may be an escape character somewhere, somehow. I have tried a lots of different syntaxes but apparently not the right one.
So if someone out there had some html coding that works for them and they'd
be happy to share, thanks in advance!
UPDATE 2, I have created an html template email after a quick training on the internet. I have tested my bit of code with litmus and it shows exactly what I wanted to see. I then paste this exact same bit of code into OpenERP, send the email message to my email client, identical to the one on litmus, and it is totally empty. However, it says the format is HTML. There is definitely an issue somewhere but I can't point out where. It seems OpenERP doesn't send the html code. Has anyone ever had the same issue???
Here is the html basic code I have used for testing and that I pasted into OpenERP:
<html>
<body leftmargin="0" marginwidth="0" marginheight="0" offset="0">
<table width="100%" bgcolor="#cccccc" cellpading="10" cellspacing="10">
<tr valign="top" align="center">
<td>
<table width="500" bgcolor="#ffffff" cellpading="0" cellspacing="0">
<tr>
<td>
liusuhflsb
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Short answer: you can't do that in 6.1 without using third-party addons or custom code.
Long Answer:
OpenERP 6.1 does not provide a WYSIWYG/Rich Text editor out-of-the-box (OpenERP 7.0 introduces that)
As a result, in 6.1, only the plain text version of a template is used whenever the user can manually edit the email contents. Indeed it would be quite awkward to ask users to manually edit the source of the HTML version of the template when composing their email (no WYSIWYG).
It is the case when you're composing a new email based on a template, via the corresponding Send Mail side bar action, because you can modify the email before sending it.
One typical case where both the HTML/Rich Text and the plain text version of a template are used as expected is when an email template is bound to a Marketing Campaign step (via the marketing_campaign module) - because these emails are sent without any editing nor any manual user action.
UPDATE:
If that's what you're interested in, Marketing Campaigns will
always send both the plain-text and HTML version of your emails
automatically, and the recipients' mail software will display the
relevant one based on user preferences (for most people it will be the
HTML version). However you can not test the templates using the
Send Mail sidebar buttons, because that will keep only the plain-text version, as explained above. There are two recommended ways
to test those campaign emails:
Use the Preview button on the template and select a sample record to render the template for. This will let you double-check the
source of the HTML that will be produced.
Test-drive your campaign putting in "manual" mode: have a dummy record enter the campaign with your email address on it, then use the
Campaign Follow-up menu to make it manually advance through the campaign steps. This is really important to validate not only your
email templates but also the structure of your campaign. See also this
basic introduction to OpenERP Marketing Campaign, from OpenERP
Community Days 2012.
There are community modules that add WYSIWYG editing capabilities to OpenERP 6.1 (search for WYSIWYG on OpenERP Apps), but I don't think they were integrated with the email_template module in order to enable composing Rich Text directly. Doing it wouldn't be very hard though. If you're interested, start by reading the source code of the mail.compose.message wizard (both the original version of the mail module and the email.template extension), to see how the template fields are used and where.
If you're not familiar with OpenERP development, the developer documentation of OpenERP and the technical memento will be interesting starting points.
The e-mail message is sent with both contents: plain and html.
The e-mail client makes the decision to render either one, depending on it's capabilities. It it's html capable, it will use the HTML version, if not, the plain version will be rendered.
You should provide the two versions for the message in your template: plain and html.
This is over a year ago and I have given up on OpenErp because of this kind of flaws. I never got around to having OpenERP send me an automated email in HTML format, no matter what I tried. It always defaulted to text whichever email client I used. I would like to know if wome other people have managed receiving automated html email that related to a marketing campaign in OpenERP?
In out project we are creating a pdf by using seam pdf and storing that pdf in the database.
The user can then search up the pdf and view it in their pdf viewer. This is a small portion of the code that is generated to pdf:
<p:html>
<a:repeat var="file" value="#{attachment.files}" rowKeyVar="row">
<s:link action="#{fileHandler.downloadById()}" value="#{file.name}" >
<f:param name="fileId" value="#{file.id}"/>
</s:link>
</a:repeat>
When the pdf is rendered, a link is generated that points to:
/project/skjenkebevilling/status/status_pdf.seam?fileId=42&actionMethod=skjenkebevilling%2Fstatus%2Fstatus_pdf.xhtml%3AfileHandler.downloadById()&cid=16
As you can see this link doesnt say much, and the servletpath seems to be missing.
If I change /project with the servletpath
localhost:8080/saksapp/skjenkebevilling/status/status_pdf.seam?fileId=42&actionMethod=skjenkebevilling%2Fstatus%2Fstatus_pdf.xhtml%3AfileHandler.downloadById%28%29&cid=16
Than the download file dialog appears. So my question is, does anyone know how I can input the correct link? And why this s:link doesnt seem to work?
If I cannot do that, then I will need to somehow do search replace and edit the pdf, but that seems like a bit of a hack.
(This is running under JBoss)
Thank you for your time....
I found a workaround for this problem.
Seems I have to use s:link together with a normal a href tag.
Only having href tag doesn't work for some reason.
<s:link action="#{fileHandler.downloadById()}" value="#{file.name}" propagation="none">
<f:param name="fileId" value="#{file.id}"/>
</s:link>
<a href="#{servletPath.path}?fileId=#{file.id}&actionMethod=#{path.replace('/','')}%2Fstatus%2Fstatus_pdf.xhtml%3AfileHandler.downloadById()&">
download
</a>
The servletPath.path returns the servlet path ie http://mydomain.com/download.seam
You can decide to put login-required=true on the download.seam if you want users to login before downloading a file.
#Observer("org.jboss.seam.security.loginSuccessful")
public void servletPath() {
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
this.path = request.getRequestURL().toString().replace("login.seam", "download.seam");
}