Save As - html thymeleaf - html

we need to develop an application similar to the below
On the web page user is asked to select the parameters which are present in a Map<String,Boolean>. Once the user selects his choice of parameters then this Map is saved in a .DAT file. Right now I am saving it in C:/Users/Application. But I want the user to choose which directory he wants to save. I was tempted to use <input type="file".....> but it needs a file in the directory.
Is there any way that the user can specify his own directory where this .DAT file is saved.
Something similar to SaveAs..

A webpage cannot choose where the user will download a file that is returned. For some file types, the browser might even show the file instead of downloading it (e.g. PDF file).

Related

Can you save an image in angular without the backend?

I want to save an image in angular's Assert folder or in a folder created by me. I occupy the input file and a button, nothing more when I save the selected image, I want it to be uploaded or copied to said folders or folder. Can this be done without the backend?
I have been looking for information and watching videos but most of them either use firebase or some other service, I just want it locally. Please, your help would help me a lot.
If I understand your question correctly, you are asking if, at runtime, you can create a file in your Angular applications' 'assets' folder.
This is not possible, because the 'assets' folder is a compile-time artifact. It only exists in your source code tree. In the compiled application, the assets folder does not exist.
Furthermore, when the folder exists, it only does so on the computer on which you wrote the application. The user is running it in their web browser, which is generally running on their computer, not yours.
Now, if you are just asking if you can save a file on the user's computer, take a look at File Save functionality in Angular

Automatically format .csv file upon download?

I have a form that will open a file based on user's selections. A few files are .csv and those files open up in Excel, as expected. However, everything is placed into one cell... I know that there is a way to manually configure it so that the | or , are delimiters, but is there a way to set it so that Excel will automatically set the | as a delimiter?
Thank you in advance!
Because you use the word "download" and your question is tagged "html", I assume that the user interacts with a web form rather than a desktop form.
In that case, it's the web browser that decides what to do with the file. If the browser recognizes the content-type of the response as something it can handle natively (e.g. "text/plain" or "image/jpeg") then it may open the file and display it directly.
However if the content-type is not something it knows how to deal with (which is likely the case with "application/csv"), then it will download the file and ask the operating system to open it. At that point, the filename assigned to the file (which can be set via the HTTP response) may come into play.
On a Windows machine, the operating system maintains a list of file extensions and actions associated with those extensions. When you install Excel, that will normally make Excel the default "open" action for files with the ".csv" extension. That's why double-clicking on a ".csv" file opens in Excel, and also why it may open in Excel if you download it from a website. (If you didn't have Excel, it may simply ask you what program you want to use).
This is a long-winded way of saying that if you had control over the user's machine you could give the file a different file extension and then associate that extension with an action that did something different. But, I assume that you probably don't have that sort of control unless you're dealing only with in-house users, and anyway it would not be a trivial thing to achieve.
I don't think that there's any way to communicate to Excel via the command line that it should use a particular delimiter when opening a CSV file, and that - unfortunately - is the mechanism by which the operating system will ultimately open the file.
It is possible to control what Excel uses as the default delimiter for all CSV files (see https://superuser.com/a/606274/18472) but again that would require you to change the system-wide settings on your users' machines, which I imagine would not be possible.

Load local image, modify it and save back to same file

File input allows user to access a local file from browser. Is it possible to load a local file given by file input, modify it and save it back to same local file? I know that HTML5 allows creating writeable filesystem, but basically it seems to be abstract directory.
For security reasons, I don't think the browser can overwrite the local file. Using the File-System API you could only copy the contents of the local file to the sandboxed File-System API directory(found under various obfuscated file names). All manipulation/saving would be done in AppData.
Perhaps displaying the modified image on the screen, right click, save-as to the given file location would also be suitable? (other than that I think you have to upload the image to a server and download it back again)

HTML 5 - load text from text files

I am facing problem in HTML 5. I need to statically load data into web page from local saved files. Up to now, I have been only able to load data via < input type="file" id="fileinput" / > but I want to load data from static location, which never changes. How to do that? And is there any way how to determine, whether some local file was changed from previous version?
Thanks
no, this isn't possible if by 'local', you mean a file at /home/waypoint/somefile.txt. You can make a 'link' with the filesystem api (if you selected it in an input field, for instance), which is valid to do computations with it (to read it, write to it, display it in img,etc). But it is deleted/unvalid, as soon as the window closes. If you could just magically "read" any local file via javascript which resides on the file system, who would stop google to read out your /etc/passwd file?
if your local computer is also your server and therefor your server-side code has access to the local file /home/waypoint/somefile.txt, your app can get it via ajax. Checking if the file exists, would be done the same way.

A web-page that would provide a user to download a certain file from it, but would not disclose the location of that file - is it possible at all?

(I am sorry if my question is not in the right place. (I've been thinking for awhile and came up to the conclusion that this one is the best place for my question)
Is it possible to create such an HTML web-page that would provide a user to download a certain file from it, but would not disclose the location of that file (i.e. the user would not know the URL of the file that he is downloading).
If yes, would you, please, give me some directions as to which HTML code I should use to create such a page.
The HTML page would provide a link to a server side script passing a filename or other unique moniker:
Download Now
The script would read the identifier, derive a full path from it, load the file and write it back with the appropriate headers/mime type causing the browser to prompt the user with the normal download dialog.
The only location data available to the user would be the link to the script - which would - unless you add some security - serve back the file just as if it were a standard url pointing to a file.
(PHP Example)
With pure html, no. But with a serverside script (php, c#, vb, perl, or other) yes. You would stream the file to user. In that case just the serverside script has access to the origin files