xtk

Loading failed for VTK files hosted on server


I'm trying to host my vtk files on a server, like this demo file http://x.babymri.org/?pits.vtk, so that I can:

p.file = 'http://x.babymri.org/?pits.vtk';
r.add(p);

However, when using my own file link for p.file, I got following error:

Error: Loading failed:   [object Object]
of.prototype.Df http://get.goxtk.com/xtk.js:234:375
bind_applyFunctionN self-hosted:1064:9
bind_invokeFunctionN self-hosted:1051:12
bound  self-hosted:1031:16
w.handleEvent http://get.goxtk.com/xtk.js:55:888
Zb http://get.goxtk.com/xtk.js:64:41
Rb http://get.goxtk.com/xtk.js:66:240
Qb/p< http://get.goxtk.com/xtk.js:60:335

Here is my index.php on the server:

<?php
$file = $_GET["file"];
$path = 'MyFolder/' . $file;    
$fp = fopen($path,"rb");
header('Content-Type: text/html; charset=utf-8');
header("Content-Length: " . filesize($path));
fpassthru($fp);
fclose($fp);
?>

I can see my online vtk file in browser using "http://my.server.org/?file=xxx.vtk". And I can load my vtk locally with xtk. However the same javascript that loads the demo file gave above error loading my online vtk. How may I change my index.php to fix the loading error? Thanks.


Solution

  • Problem solved, thanks to the prompt response from Dr. Daniel Haehn (DANIELHAEHN.com)! After changing the index.php to following, the loading succeeded:

    <?php
    $file = $_GET["file"];
    $path = 'MyFolder/' . $file;    
    $fp = fopen($path,"rb");
    header('Content-Type: text/html; charset=utf-8');
    header("Content-Length: " . filesize($path));
    header("Access-Control-Allow-Origin: *"); //added this line
    fpassthru($fp);
    //fclose($fp); //commented this line
    ?>