ExtJS 3 export textarea content to a text file - extjs

I need to export the contents of an ExtJS TextArea to a text file. I searched around the documentation but I didn't find anything related to a textarea. Is this possible?
It would be also ideal to prepare the filename as well together with the ability to export the textarea content to the file.
Help is appreciated.
Thanks

You can't just save something from JS file into any place on user's local computer file system. It's huge security hole and it's just doesn't work this way. You have couple options however:
Send this information to your server and provide user with a link to a file. User clicks that link server will respond with the information - browser saves that data. You can even make so content will automatically be downloaded by the browser (well, by most of them anyway)
Or you can ask user to right click and copy this information into the clipboard.

Related

Download PDF in React

I'm working on an api which returns a PDF link. I can put that link into a button, and when users click on that link, it'll download a PDF to their computer. I wonder if there is a way, so that when users click on the link the first time, it'll download the file. But if they click on the link the second time, it just opens a modal with the PDF content inside of it? That way they don't have to download the file again and again.
It's confidential so I can't tell how the link look like, but it's a PDF link stored in s3 aws.
You can do it but you need to store the information that if the user clicked the button before or not. The options for storing that information is:
Local Storage
Cookie
Your backend
I would suggest not to involve your backend on this, you can just write to localStorage when user clicks that link for the first time and set something like pdfDownloadedPreviously. If you have multiple pdfs like this, you would need to define a unique key for each of them so they don't override each other.
And in your program logic, you can read this from the localStorage, if that key exists in the localStorage then you open your modal, otherwise download.

How to open a generated file on Vaadin Flow?

On my app I want to open a generated PDF with PdfBox on a new tab, I have seen a couple of documentations but they are for old version of Vaadin or won't work in my case. I don't want to save it on the server or attach the file to any link or button, I want to write a method to automatically open it on a new tab.
PdfBox gives an option to save the file on an OutputStream, is there any way to open that OutputStream file on a new tab? Or at least download it without attaching it to an Anchor widget like Flow Viritin does?
The problem lies in the fact that because you don't want to save the file on the server, you cannot then have a direct url of said file to link to. You also cannot pass the pdf file as parameter to another View.
The solution is to store the pdf in the VaadinSession (as byte[] is probably easiest), and when the user then opens another tab by clicking a certain anchor/routerlink, that view will read the pdf from the VaadinSession and add the it to the view. (How to display pdf with Vaadin 14). Please remember to remove the pdf again from the VaadinSession :)

download file which redirects?

I've tried to search for this both on Google and StackOverFlow, but simply can't find what I'm looking for, it might be that it's simply not possible, but thought I would ask anyway.
I'm looking for a way to make a file redirect the user to another page, the user would download the file by clicking on a button.
It's for a Prestashop downloadable product, I'm trying to redirect the user to another part of our site (which isn't directly visible) to be able to view magazines, etc. in a viewer.
Now Prestashop is natively set up to download the file, which is what we don't want, hence the use of the viewer, but there is no way to simply provide a link to send the user to instead of a physical file, like a PDF or something. I can't really modify the button as its generated by Prestashop, and if I add a PDF file with the link in there it defeats te purpose as I dont want people having the link in a document (I know they can find it from their history and so on). Hence I thought it would be easier to do it with a document that redirects if possible.
So in short, is it possible to make a file that would send people to a certain web page once they open/download this file on/to their computer?
And if yes, how would one go about it?
Can you make the user download an HTML file? If so, you can use "meta refresh" to redirect the user to your private page.
This does mean the unprotected link will be visible in downloaded HTML file - perhaps you can obfuscate this with JavaScript to make it a little more difficult for users to find your protected URL.
http://www.w3.org/TR/WCAG20-TECHS/H76

IE file download box get location

i am currently working on a issue where i need to get location of the file downloaded.First let me explain the scenario.
I placed a link in my page and when user clicks the link it shows file download dialog with open/save/cancel options in IE.Now when the user clicks on the save button and choose a location to save the file i need to get that file saved location using whatever options possible.
Thanks!
I do not think you can... at least not easy. This runs on the client, and for security reasons you can not acces the client's filesystem with javascript.
Maybe it is however possible using a flash or silverlight plugin, as the user can allow access from within these applications to the local filesystem. It might be very difficult tho...
The browser will not allow you to access information about the clients filesystem.

How to auto generate a webpage after user submits form

I am looking for some initial direction on this one because I cannot seem to find my way with it. Let me explain...
I am developing a website wherein a logged in site member (Joomla 1.6) can fill out a simple form and attach a pdf to be uploaded upon submission. The user then clicks the submit button and the page will refresh to a new and unique web page.
User Submits data on http://www.examplesite.com and then after submission a new web page is generated that is called http://www.examplesite.com/userSubmittedValue
This newly generated web page would come from a template that is specified by the administrator and, most important, it will display all of the information that the user submitted. Also, there would be a link to download the pdf they uploaded. The user could then view a list of all the pages they have created in this manner via their profile.
I have seen this all over, but I am at a loss for how to generate this. Any help is much appreciated.
This is not something you will be able to easily do or get a detailed answer for here. If you just wanted to do the submission form with a thank you page that shows the data submitted you could use any number of form wizard type extensions - http://extensions.joomla.org/extensions/contacts-and-feedback/forms
If you just needed a way for users to upload PDfs and have access to them you could use one of the file management extensions that offer front end upload features - http://extensions.joomla.org/extensions/directory-a-documentation/downloads
If the additional data that is being submitted is simply data related to the file - title, description, etc then one of the file download components should work fine for you. The choices are limited in 1.6 at this time though so you might have to go with 1.5 to get the extension that works best for your needs.
So this probably isn't the best way to do it if your using Joomla but it just might help.
I would use PHP and inside of you're directory have a file like "template.html". Then I would create some php to handle the task of....
Opening "template.html"
Finding and replacing the values that the user passed you
Save the "template.html" under a new name (userSubmittedValue.html)
Again, I never really use Joomla. If you were to try this I'd suggest checking out php's file system functions (http://us2.php.net/manual/en/ref.filesystem.php).
Hope this helps a bit.

Resources