アップロードされたファイルを受け入れ、そのファイルの内容を解析して特定の形式で表示するようにページを変更する必要があります。
ファイルを解析するコードがありますが、現在、サーバー上の静的ファイルを読み取り、文字列として読み取ります。代わりに、アップロード後にファイルの内容を文字列に入力する必要があります。
PHP/JSを使用してこれを達成するための最良の方法は何ですか。可能であればPHPはまったく使用したくないのですが、使用する必要がある場合は問題ありません。
他のオプションも大歓迎です。
ありがとう
編集:
ありがとう-私はまだいくつかの変更を加えているので、すぐにコードを投稿します。
これはばかげた質問かもしれませんが、私はAJAXに精通していません。
ファイルは任意の場所にアップロードする必要がありますか、それとも一時的に変数に格納できますか?
使用する必要のあるファイルは
http://distributome.avinashc.com/howardL/scripts/distributome.js
特に、行xmlDoc = xmlhttp.responseXML;
操作を使用してファイル「Distributome.xml」を開いています
xmlhttp.open( "GET"、 "Distributome.xml"、false);
代わりに、ユーザーがアップロードするXMLファイル(または2つ)を使用してデータを入力します。
タスクの別の部分として; 異なるデータが含まれるように、2つのファイルを使用する必要があります。そのため、今のところ、コメントした行に2つのファイルを追加しています。
編集:
{
/*
Split into distributions and relations - but append them
xmlhttp.open("GET","Distributome.xml",false);
xmlhttp.send();
if (!xmlhttp.responseXML.documentElement && xmlhttp.responseStream)
xmlhttp.responseXML.load(xmlhttp.responseStream);
xmlDoc = xmlhttp.responseXML;
xmlhttp.open("GET","Distributome-references.xml",false);
xmlhttp.send();
if (!xmlhttp.responseXML.documentElement && xmlhttp.responseStream)
xmlhttp.responseXML.load(xmlhttp.responseStream);
xmlDoc = xmlDoc+xmlhttp.responseXML;
*/
getURLParameters();
/*** Read in and parse the Distributome.xml DB ***/
var xmlhttp=createAjaxRequest();
xmlhttp.open("GET","Distributome.xml",false);
xmlhttp.send();
if (!xmlhttp.responseXML.documentElement && xmlhttp.responseStream)
xmlhttp.responseXML.load(xmlhttp.responseStream);
xmlDoc = xmlhttp.responseXML;
try{
DistributomeXML_Objects=xmlDoc.documentElement.childNodes;
}catch(error){
DistributomeXML_Objects=xmlDoc.childNodes;
}
traverseXML(false, null, DistributomeXML_Objects, distributome.nodes, distributome.edges, distributome.references, distributomeNodes, referenceNodes);
xmlhttp=createAjaxRequest();
xmlhttp.open("GET","Distributome.xml.pref",false);
xmlhttp.send();
if (!xmlhttp.responseXML.documentElement && xmlhttp.responseStream)
xmlhttp.responseXML.load(xmlhttp.responseStream);
var ontologyOrder = xmlhttp.responseXML;
getOntologyOrderArray(ontologyOrder);
}
編集:
ファイルをサーバーにアップロードしていません。代わりに、ユーザーがローカルにアップロードするときにコンテンツを解析するだけです。