Search code examples
javascriptadobeadobe-indesign

Indesign Javascript load a file from serverpath


I have a problem with Indesign. I have a document, where I want to add a picture programmatically. This is easy, when I use a picture on my localdrive. But I want to add a picture from a server path like \myserver\pictures\pic.jpg

I tried it like I add a picture from localdrive

var f = new File("\\myserver\pictures\pic.jpg");
imgPicture.place(f, false);

Then the value in f is

//myserver/pictures/pic.jpg 

I build a try catch around it. The errorMessage is undefined. I get the same error, when i use the networkdrive letter, like

/x/pictures/pic.jpg

As i saw in the documentation for the file-object, there is only one string-parameter for the path.

Is there a solution? On an other forum, I found a thread where someone had the same problem. But he did a dirty way to solved it. He did a fileOpenDialog and pasted the link to the file and then it downloads the file to the temp directory.

I can't do this, because I have on my server about 100,000 pictures.

Thanks for help.


Solution

  • Another issue of yours may be that backslash may be interpreted as escaping character thus resulting in something like : \myserverpicturespic.jpg" So you may need to escape the escaping character like : "\\myserver\pictures\pic.jpg" and then pass this string. Finally, when I have a doubt about a file path, I usually use this bit of code :

    var f = File.openDialog();
    if ( f ) $.writeln ( f.fsName );

    FWIW

    Loic