• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Execute a PHP file from a script written in Javascript (InDesign)

Guest
Jul 19, 2011 Jul 19, 2011

Copy link to clipboard

Copied

Hi,

I'm working on a web base application, and I need to execute a PHP file in a script written in Javascript (InDesign).

I only need to "open" this file (like a page in a Browser), I don't need to work with it. I only need to have that page (file) executed.

Someone can provide help, please?

Thanks and best regards.

TOPICS
Scripting

Views

1.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 19, 2011 Jul 19, 2011

Copy link to clipboard

Copied

Hi,

On windows you can do something like this:

  • Create a shortcut to your php webpage and save it somewhere on your computer
  • Use the code below to open the shortcut:

    var file = new File("file:///C/Temp/Shortcut.url");
    file.execute();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 19, 2011 Jul 19, 2011

Copy link to clipboard

Copied

Hi 2i Geert and thanks for the idea.

I have made it with:

reply = "";

conn = new Socket();

if (conn.open("192.168.91.184:8888)) { // my port and host

conn.write(" GET /myfile.php?" + variousVariable + " HTTP/1.0\n\n");

reply = conn.read(999999);

conn.close;

}

With this code, the myfile.php seems to been executed.

But I'm still searching for a better solution.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 19, 2011 Jul 19, 2011

Copy link to clipboard

Copied

The answer is No.

You sound awfully confused. Web browsers do not execute PHP scripts -- web servers do. So your analogy ("like a page in a Browser") doesn't make any sense.

I do not understand what you mean by "open". That doesn't seem to have anything to do with executing.

But in any event, InDesign does not include a php interpreter.

I suppose you could use an external PHP interpreter to evalute your PHP code, but it dosn't seem like a very good idea and probably wouldn't work for oyu, even though it could theoretically.

What is it that you are trying to accomplish? Please include a realistic example, because what you're asking just doesn't make any sense.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 20, 2011 Jul 20, 2011

Copy link to clipboard

Copied

The answer is Yes

However, I managed to make it work with the code I have written above, so it's possible.

The example:

I'm working on a plugin for InDesign, and I have some Javascript scritps.

One of these scripts need to call a PHP page that is present on a server. I use the code above to call it (with variables and GET) and make it execute.

It's the server that actually execute the PHP code, but only when my Javascript script's call it.

And this work fine, so, this is possible

Anyway, I'm still wondering why it works...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 20, 2011 Jul 20, 2011

Copy link to clipboard

Copied

Well, sure, if you want the SERVER to execute the PHP then that makes

perfect sense. That's not what you asked for, though. It is easy to

change a No into a Yes by changing the requirements.

You say you are wondering "why it works"? What is the question?

Why would it not work?

InDesign can be a web client, just like any other browser (have fun

rendering anything you get back that's in HTML, but that's a different

story.)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 20, 2011 Jul 20, 2011

Copy link to clipboard

Copied

Alt!

I do not want and did not want to disrespect anyone.

I surely write wrong problem specifications, but the important thing is that we found a solution.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 20, 2011 Jul 20, 2011

Copy link to clipboard

Copied

LATEST

OK, so you're all set! Great! I thought you had another question...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines