0

I need to be able to grab specific files (only text files) using the tag, hosted on SVN server. The user would type in their username and password as well as the name of the file like this:

Username: John 
Password: ***** 
Filename: mySite.html

this is the section I have with the form:

<form id="loginForm" action="requestFile()" method="post">
        <div id="loginWindow">
            <p class="signInText">Username</p>
            <input type="text" name="username" id="username" required="required" />
            <p class="signInText">Password</p>
            <input type="password" name="password" id="password" required="required" />
            <p class="signInText">File Name</p>
            <input type="text" name="filename" id="filename" required="required" />
            <input type="submit" value="Ok" id="submit" />
        </div>
</form>

Once the user clicks 'OK', the website will request the file from the server and copy the file's text contents into a textarea on the same page. The user can then work on their file and later click a 'Save' button to copy the contents back to the server (probably by replacing the original file). The 'Save' functionality is something I'll think of later, but I need to establish a connection to the server and request and receive the proper files.

The server can be accessed via a website which will have an authentication popup to ask for username and password, after which it will display a list of the contents at that location. So for example wwww.myWebServerLocation.com:8080/svn/Folder/file.html will request a username and password and then display the contents of the file in the browser. I just need to get these contents into my textarea using .

EDIT: I have not implemented the 'requestFile()' function. That's what I need a little direction in implementing.

VagrantC
  • 687
  • 2
  • 13
  • 31

1 Answers1

0

You will need to make a cURL request from your server with the appropriate authentication headers to provide username and password.

I am assuming you are using PHP on the server-side: This should help you implement a solution: How do I make a request using HTTP basic authentication with PHP curl?

If you are trying to do this simply using JavaScript in the browser, you wont be able to pull this off due to the cross-domain policy that prevents you from making a request from your Javascript to an external domain.

Community
  • 1
  • 1
Abdullah Khan
  • 2,384
  • 2
  • 22
  • 32