Hi there
I am trying to upload a file using type = "file" in aem front end and I want to read that file using servlet and get the data of the file. I already have a servlet in which I have hardcoded one link but I want to get the link of the file uploaded using the button in that place and get data of the file.
Can anyone help me with this?
Thanks in advance!!
Views
Replies
Total Likes
When you add attachments to an adaptive form, the attachments are stored in a temporary location in the CRX repository.
You can also create a servlet to store the form attachments in a new location in the CRX repository and then access the file directly.
String fileName = attacmenPath.split("/")[1];
InputStream is = request.getPart(attacmenPath).getInputStream();
Document aemFDDocument = new Document(is);
String crxPath = saveDocumentInCrx("/content/afattachments", fileName, aemFDDocument);
Hope this helps!
Hi @Pulkit_Jain_, I don't want to save the uploaded attachment, it's just after uploading file using one button and on click on submit button, my servlet which gets active by the submit button should take the absolute path of the uploaded file and should be able to read the data in that file.
or can you help me get the absolute path of the uploaded file in aem js itself?
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
@sushmapoojitha " absolute path of the uploaded file", So you want to expose part of your server with an absolute path that is accessible to an external user, Not a great idea.
How many links do you want to show on the form?
Views
Replies
Total Likes
@sushmapoojitha Why not just create a custom file upload widget and as users upload the file convert it to base64 and create an HTML link in the form. You don't need a servlet for this, it can be done in vanilla JS.