1

I'm trying to implement a feature where a user clicks a link, then it would open a txt file and then it could be edited and saved inside the browser (similar to Google docs).

I've read this in hopes of finding a solution but it still doesn't work. The closest I've reached is to display the txt file in the browser:

<a href="test.txt">Click</a>

But this requires the file to be in the root folder of the website. When I try to put something like file:///SERVER/PATH/test.txt, Chrome will respond with an error saying that 'local files can't be accesed'.

Is what I'm trying to do even feasible?

Lee Merlas
  • 430
  • 9
  • 24

2 Answers2

0

If you are running this in IIS and you want to access a text outside the root folder and. Then you can create a virtual directory to map it to file:///SERVER/PATH/. Then you can access it in a tag easily.

Jokies Ding
  • 3,374
  • 1
  • 5
  • 10
  • can you provide some simple code as to how to implement this? I'm fairly new with IIS – Lee Merlas Jul 29 '20 at 23:30
  • @LeeM https://learn.microsoft.com/en-us/iis/configuration/system.applicationhost/sites/site/application/virtualdirectory This is the link about how to set virtual directory. You can map it to our UNC path and then replace application pool identity with a domain user that have permission to access that folder. If yo create a virtual directory named" Path". Then you can access txt via http://domain/Path/test.txt" – Jokies Ding Jul 30 '20 at 06:49
0

I see a [html] tag, so i will answer as a website developer.

Your case:

When you click a link by browser, as "test.txt" or "http://localhost/test.txt", or any link in any server, you want open file "test.txt".

We have a lot of thing need to attend:

Link test.txt is a link what is provided by server, and access by your browser to download, it's NOT a direct file. So you can't edit that file direct by your browser.

Sometime, you will open another tab in browser to edit as Google Docs. It's not simple as you see, "just open a editor". It's a website application, develop by some language as Javascript, HTML, CSS, PHP/ASP ...

If you want to "it could be edited and saved inside the browser", you must write a website application as Google Docs.

It's easy if you are website developer, but will hard if you are not.

If you specially want to edit and save file by using Google Doc, you can use Google App Script, you can read/write docx, xlsx from your website application with API.

If you want to read the data from excel file, then be able to edit and save it as well in the web application, by ASP server side code.

You need do some big work to do:

  1. read data from excel file.
  2. Display into your website application.
  3. Make a some input/text area/table or anything you want, to allow people can edit what they want.
  4. Save what people edited into your excel file (or database)

Try this link if you want to use pure ASP.

Try this link if you want to use library.

After try them, you can ask another question for more detail, when you know more.

This is a case similar to your case

Trần Hữu Hiền
  • 872
  • 1
  • 9
  • 22
  • I'm a web dev, and I asked this question just to see if it's possible. I said 'like Google Docs' to imply that I can edit and save via browser but I can't use Google Docs since it's against the requirements. My main goal is to actually open, edit and save an Excel file all inside the browser via HTML link, so I used the `txt` file as a simple example just to test the theory – Lee Merlas Jul 29 '20 at 23:28
  • If you specially want to edit and save file by using Google Doc, you can use Google App Script, you can read/write docx, xlsx from your website application with API. https://developers.google.com/apps-script – Trần Hữu Hiền Jul 30 '20 at 01:16
  • .txt is a ambiguous case, because there is a lot of way to view/edit/save file .txt in browser. That's why i want to know more information from you. – Trần Hữu Hiền Jul 30 '20 at 01:18
  • Oh I see. But in this case, I'm trying to open and save it without the use of any Google Service. Requirements state that Microsoft Excel must be installed as well. So it's sort of automating the Excel file so I can open and edit it inside browser – Lee Merlas Jul 30 '20 at 01:40
  • Do you try to read data from excel file (xls, xlsx) in your web application? or want to know how to do that? – Trần Hữu Hiền Jul 30 '20 at 01:53
  • Yes, without downloading the excel file, I want to read the data from excel file, then be able to edit and save it as well in the web application. – Lee Merlas Jul 30 '20 at 02:03
  • Yes, it's ASP for IIS – Lee Merlas Jul 30 '20 at 02:42
  • It's a big work, as I said before. You need do some big work to do: 1. read data from excel file. 2. Display into your website application. 3. Make a some input/text area/table or anything you want, to allow people can edit what they want. 4. Save what people edited into your excel file (or database) – Trần Hữu Hiền Jul 30 '20 at 02:50
  • Try it: http://www.crydust.be/blog/2009/03/02/generate-excel-files-in-asp-classic/ if you want to use pure ASP – Trần Hữu Hiền Jul 30 '20 at 02:51
  • And this https://demos.devexpress.com/ASPxSpreadsheetDemos/ if you want to use library – Trần Hữu Hiền Jul 30 '20 at 02:52
  • After try them, you can ask another question for more detail, when you know more. This is a case similar to your case https://stackoverflow.com/questions/440892/how-to-output-an-excel-xls-file-from-classic-asp – Trần Hữu Hiền Jul 30 '20 at 02:52
  • Thank you for the links, yes I think there will be some big work to do. I'll try out the links you gave and see if any of them helps. – Lee Merlas Jul 30 '20 at 03:28