Open a external File, a TXT

Hi.

I need open a document in my local computer using my app.

I tried:

<a target="_heopenit" href="D:\Dropbox\work example\source\uploads\document.txt">Open Documentation</a>

<a target="_heopenit" href="heopenit:D:\Dropbox\work example\source\uploads\document.txt">Open Documentation</a>

In the first code, when I click it doesn’t nothing.
In the second code, when I click it open a new windows but empty.

Please could help with it?

The path in “href” is wrong: it must be a relative path. To open an external file (such as your text file), refer to the Chromium demo that ships with ExeOutput. In this demo, we open an external text file: you’ll find all the code.

Ok I understand that with “heopenit://” I can open files in my folder DATA but in this case, I want to open files in others paths, in differents paths.

I think I must do a copy of this file in my DATA path for I can open it, is it okay?

I will copy it in my app folder and I could called :

<a target="_heopenit" href="heopenit://datadoc.txt" class="btn btn-danger btn-sm">Open</a>

Is it ok?

For that, you don’t have to use heopenit://
See our demo, as explained, it tells you how to open external files.

Okay, I do not understand the examples. Here it says “Accessing external files …” but it accesses to TXT into DATA using DOCUMEN_ROOT. That is to say, it is an internal file, it is not an external file.

If my app is in C/:PRG/DATA/RUN.exe, Can I open a TXT in D:/more/sal.txt ?? or do I must copy this TXT in my folder DATA ??

PD: My app generates the TXT in the location that the user chooses, and then I want to open that TXT with a button

Regards

It explains how PHP can access external files (which means files not compiled into the EXE).

For your case, to open any text file provided you know the location, do this:

  1. Create the HEScript function. Open your ExeOutput project and go to the Scripting page. Double-click the “UserMain” script to open the script editor.

  2. Add this function code:

    procedure OpenAFile(Filepath: String);

    var

    res: integer;

    begin

    res := OpenFile(FilePath, “”, SW_SHOWNORMAL);

    if res < 32 then

    begin

    MessageBox("Error while opening: " + FilePath + ". Error code: " + inttostr(res), “Launch Error”, MB_OK+MB_ICONERROR);

    exit;

    end;

    end;

  3. Click Save Script.

  4. Edit the HTML page with the links that should open the file. Just replace the links with the HTML code:

<a href="hescript://UserMain.OpenAFile|PATH TO YOUR DOCUMENT">Open my document</a>

In your case, this would be:

<a href="hescript://UserMain.OpenAFile|D%3A%5Cmore%5Csal.txt">Open my document</a>

As you can see the path D:/more/sal.txt has been encoded for URLs: D%3A%5Cmore%5Csal.txt

1 Like

COOL !! it works!

Thanks for support.

I followed that with a simple try to open link to a file. But I get error :

fopen(): Unable to find the wrapper "hescript" - did you forget to enable it when you configured PHP?

I use PHP7.1 and I looked through forum and found nothing aboout how enable hescript wrapper

Please advice solution.

Alex

O.k. solved that. one issue still open.

Hi,

I need some assistance.
I am trying to open a excel file in MS Office on my local machine by clicking a hyperlink

procedure OpenAFile(Filepath: String);

var

res: integer;

begin

res := OpenFile(FilePath, “”, SW_SHOWNORMAL);

if res < 32 then

begin

MessageBox("Error while opening: " + FilePath + ". Error code: " + inttostr(res), “Launch Error”, MB_OK+MB_ICONERROR);

exit;

end;

end;

This solution seems not to work. Some script error if I copy this into UserMain

Any advice?

tnx.

Which error do you get? Take care of " characters. In OpenFile, you have “”. It should be "".

Hi
Yes, error is gone. Is was a Script Error message in the HEScript editor.
It is working now. I fixed the typos.

Thank you.

1 Like