I have a .desktop file and I want to read the icon png image file path in javascript so I can display it in my html file. How would I go about doing this?
This is what my .desktop file looks like:
[Desktop Entry]
Version=1.0
Name=BackMeUp
Comment=Back up your data with one click
Exec=/home/alex/Documents/backup.sh
Icon=/home/alex/Pictures/backup.png
Terminal=false
Type=Application
Categories=Utility;Application;
Any help would be greatly appreciated!
If the javascript you saying is only the javascript in browser, it's impossible except you upload the file to a server and analyze it.
1.browser javascript and server
First of all you should have a form that you can upload your .desktop file, and then you upload to a server(you can use node.js to build a server).
After the server received it, you can read its content as text and find the line of Icon and then response to browser
2. serverside javascript: node.js
if you can use node.js for reading this file, it's much easier.
just install node.js and build a .js file and use fs.readFileSync to read the .desktop file and analyze it line by line.
Related
I have a html file under my war folder in the project ,
I just want to access that file From the path "/myhtml.html"
and then replace whatever is in this file from a new text "Some new Text"
so that My html file now will only have "some new text" there .
I searched alot for this , but they provide example for changing a specific div etc in a file , but i just want to replace everything in a file which is present under a war folder.
I understand that you are trying to change the content of HTML files using Javascript that is running in the browser.
Front-end Javascript can't access local files that are stored on your machine. It would be a security disaster if it could. The only way Javascript can read with local files is using a file upload input, and it will only be able to read the files not update/overwrite them.
NodeJS however is capable of accessing the local file system. NodeJs is backend JavaScript so it will be running on a server.
I have a project where I visualise data from a file (say, a CSV). My visualiser is a .html bundle created with Webpack. Up until now, I include a placeholder for the data as a string in the bundle. If I want to change the data, I replace the placeholder in the bundle .html file with the new data I want it to show (via an external script).
Now I'd really love to change this for convenience. For example, I'd like to get a list of all the supported files that are in the same directory as the .html file and load their data, either in the background or when I click or them or whatever. (In the easiest use-case, there would just be 1 data file in the directory and the project would just load this data automagically at startup.)
I had a look at Handlebars.js and I think it might help with the injection of the data. However, it seems that there is no possibility to read from the directory I start the .html file from. I already tried fs and path but those don't work in the browser when I just want do double-click the .html file.
Is there a possibility for the browser to read files from the directory I open a .html file from? And if so, how can this be done in Javascript/Typescript?
I want to download file from external server but after renaming it. Let's say http://playtictactoe.atwebpages.com/logo.png is an image file I want to download. I have used the following HTML:
<a href="http://playtictactoe.atwebpages.com/logo.png" download="myName.png">
Download File
</a>
But this doesn't rename the file. I've read somewhere that this is because of Response Header on server. Is there any way to ignore Response Header on client side? Else guide me any other solution.
You can download the file as a buffer and resave with the file api like descriped here:
HTML5 File API downloading file from server and saving it in sandbox
Or lookup FileAPI and XMLRequest to Buffer. You download the file as binaryBuffer save it with fileAPI and rename it. This should also work in Firefox. But this is not the simple solution you are searching for. Even though it works ;-)
You can then rename the file like you want.
Cheers
Is their a way- client side,
to add text to a file named text.txt in javascript?
In python:
f = open("text.txt","w")
f.write("Hello World")
f.close()
would write "Hello World" into the text file. I want to do something similar with javascript.
Note: I am running these files locally.
Its a bit more tricky than in python.
The problem is that the browser sandboxes your session and your possibilities.
It is possible to request storage space and read and write files in that space.
More info: http://www.html5rocks.com/en/tutorials/file/filesystem/
It would be a security nightmare if a javascipt file could just open files in the root or any other folder.
A different approach would be to upload the file in the client/ to the server edit it and send it back in a response.
I'm trying to use uploadify control in MVC3. It works fine for uploading files.
Here is my problem:
How can i get the files in .zip file ?. Let me clear the question.
Here is a zip file (say : images.zip). It contains 3 jpeg files.
Now if i upload the images.zip file using upload control on my view page i need to get all the image files in the zip file.
If i uplaod images.zip file it should show all the images like this
I dont know how to get the files and how to start.
I've searched google but didnt get any clue about this.
How to get this? If any Jquery or Javascript code is avaliable please post.
If you can use .NET 4.5, there is a new ZipFile class that will let you get properties of a zipped archive.
If you're under 4.5, you will need a 3rd party zip file library, like SharpZipLib or DotNetZip.