upload files using XTRF REST API - xtrf

I have tried a form submit with files example all the files are getting uploaded to XTRF and getting the response.
Now I am using blueimp jquery file uploader[http://blueimp.github.io/jQuery-File-Upload/]. If I upload image files it is getting uploaded to XTRF. If I upload any other files it is not getting uploaded to XTRF. I am getting workfile.rtf as response with junk data.
Please help me in solving this issue.
Need to upload files to XTRF using ajax uploader.

POST /system/session/files
Accepts files encoded as multipart/form-data and stores them temporarily (they are available only within current session). Each file gets its own id and basic statistics: number of characters (with and without spaces), words, lines, pages.
sample html form for file upload
<form id="upload" action="baseURL/system/session/files" method="post" enctype="multipart/form-data">
<label>Select a file:</label>
<input type="file" name="file" size="45"></input>
<input type="submit" value="Upload"></input>
</form>
You can also send plain text assigned to parameter content encoded as application/x-www-form-urlencoded. Such text will be stored as uploaded file.
sample html form that sends text for upload
<form id="sourceText" action="baseUrl/system/session/files" method="post" enctype="application/x-www-form-urlencoded">
<label>Source text:</label>
<textarea name="content" rows="5" columns="40"></textarea>
<input type="submit" value="Save"></input>
</form>
Uploaded files can be attached to quote request or while updating user's profile.

Related

How to upload a Photo and save it into website using Python Flask

I am having trouble allowing users to upload a photo into my website and have it save to a folder so that the photo could be used later on. My goal is to have my program guess the shape that was submitted.
I so far have the html code in which allows a user to upload a photo onto my website but when the user submits it, it goes no where.
HTML:
<div class="w3-third">
Your image: <input type="file" name="pic" id="pic"><br>
<input type="submit" value="Submit">

Attach file from my local machine to send mail in cq/AEM

I am learning AEM and I am working on a requirement where in I am able to send email message however I am unable to add attachments that are browsed from my machine.
Requirement -
There is a form made in HTML from where info is collected and there is a browse button from where a file can be uploaded.
As soon as the file is uploaded an email should be sent to an email address with form content and with the attachment.
Also at the same time, through a POST request the form content and the attachement should be sent to a JSON
Sending the content via email to the receipient and to the POST method is working fine.
Any suggestions on how can I get attachement working in this ?
Thanks!
In HTML, You can fetch the file from input box with type "file" as ::
<form id="submitForm" action="/bin/servlets/submitForm" method="POST" novalidate="novalidate" enctype="multipart/form-data">
<label for="name">Name </label><input name="userName" type="text" class="fieldInner" id="name" required>
<input name="file" value="Choose File" type="file" class="chooseFileInner" required/>
<input type="submit" id="applied" value="Submit"/>
</form>
in java, you can fetch this file as ::
RequestParameter attach = request.getRequestParameter("file");
InputStream ip = attach.getInputStream();
MailTemplate mailTemplate = MailTemplate.create(templatePath, session);
HtmlEmail email = mailTemplate.getEmail(StrLookup.mapLookup(new HashMap<String, String>(parameters)), HtmlEmail.class);
ByteArrayDataSource fileDS = new ByteArrayDataSource(ip, "application/pdf");
email.attach(fileDS, "application/pdf", "This is your attached file.");
messageGateway = messageGatewayService.getGateway(HtmlEmail.class);
messageGateway.send(email);
You can also refer this Link to send images in email in aem

can you append form data to a URL in a phonegap webapp?

In my phonegap webapp, I have a form with some serious GET action on it. When I click submit, I want to open a new page and extract the form data from the URL with javascript.
Question: can you do that in a phonegap app, when you're not actually in a browser?
Yes, you can! It's as simple as I said:
<form action="destinationpage.html" action="GET>
Input your data:<input type="text" name="data /> <br />
<input type="submit" value ="Continue">
</form>
Then see the answer to this question for retrieving your data on the next page!

HTML form uploading file

I have been developing an application that allows a user to upload files to the server. I had working forms until recently, when suddenly they stopped working.
All the forms that do not work any more are the forms that have the enctype='multipart/form-data'. But the other forms that do not have this works perfectly. I've checked the spelling, and I checked everything.
It generates undefined indexes which really annoys me because it worked before. How can I resolve this?
<form method="post" enctype="multipart/form-data" action="uploadfile.php">
<input type="file" name="memofile"><br>
<input type="submit" name="submit" value="Test">
</form>

How to capture current dynamic output of JSP and email it?

In my webapplication, a JSP page outputs to the webpage, the list of users logged in that day. I want to mail the same output to specifics mail-ids. What all Struts2 tags do I need to use?
Grab the HTML using JavaScript and send it as request parameter.
<div id="content">
... (here you should put content which you'd like to mail)
</div>
<form action="mail" method="post" onsubmit="html.value = encodeURIComponent(document.getElementById('content').innerHTML)">
<input type="hidden" name="html" />
<input type="submit" value="Mail this document" />
</form>
It'll be available as request parameter with name "html" in Struts2/Servlet side. The emailing job can be done with help of JavaMail.