I need help with something i’m working on.
I need my PHP code be able to read an uploaded file “A” and write a whole new file “B” with the very same words from A but in a different order
for example if A is
ABC 54 DOG 90 100
56 11 78 YOU 101
A C F H 99
B should be
DOG ABC 90 100 54
78 56 YOU 101 11
F A H 99 C
(so 3rd-1st-4th-5th-2nd. just an example)
What I had in mind was to do something like fwrite($B,JavascriptFunction($A))
but, once into the js part, I really don’t know how to take the right word and put it into the text variable that javascriptfunction have to return.
I know I have to use a .split(‘\n’) to deal with the different lines, but that’s as far as I’ve figured out so far. I know it is probably a silly question but i’m really new to JS.
Thank you
I dont think you need Javascript to read file, but here it goes:
var fileContent=''; var theLocation=''; function readFileViaApplet(n) { document.f1.t1.value='Reading in progress...'; document.ReadURL.readFile(theLocation); setTimeout("showFileContent()",100); } function showFileContent() { if (document.ReadURL.finished==0) { setTimeout("showFileContent()",100); return; } fileContent=document.ReadURL.fileContent; alert(fileContent); // do what you want with the content }Hope it helps