Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8462977

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:20:06+00:00 2026-06-10T14:20:06+00:00

Below is my javascript function that makes an ajax call via post. It sends

  • 0

Below is my javascript function that makes an ajax call via post. It sends a file location and the contents of a file to a php page that saves the file. The idea is so users can manage config file templates for a small application via the browser instead of manually logging into remote servers, making edits, and submitting the edits back to src control to be pulled into each application (it’s all automated on the page that this ajax call posts the data to).

My problem is with fileloc. I CANNOT get my ajax call to post the fileloc and keep the dir structure intact. I’ve tried escape(), encodeURI(), encodeURIComponent(), and JQuery’s versions of these functions. No matter what, my fileloc comes through on the saveConfigTemplates.php page as: “D:TestPHPconfigurationautomationtemplatesservernamefilename.cfg”. I’ve tried php’s decode and it doesn’t make a difference… it’s like the post loses all encoding and treats the single slashes as escape chars. Driving me nuts, any suggestions are appreciated.

function saveFile(){
        var fileContents = $("#fileContent").val(); 
        alert(fileContents);
        var fileloc = "D:\TestPHP\configuration\automation\templates\servername\filename.cfg";
        var fileconts = "fileloc="+encodeURIComponent(fileloc)+"&fileconts="+fileContents;

            $.ajax({
            type: "POST",
            url: "saveConfigTemplates.php",
            data: fileconts,
            success: function(data) {
                alert(data);

             }
            });

        }
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:20:09+00:00Added an answer on June 10, 2026 at 2:20 pm

    escape the backslashes:

    var fileloc = "D:\\TestPHP\\configuration\\automation\\templates\\servername\\filename.cfg";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to call a PHP function using AJAX. Below is the script
in my asp.net application, two buttons call a javascript function called refreshView, below is
I have Javascript as below: <script type="text/javascript" language="javascript"> function redirectToPrevious(abcURL) { window.location.replace(abcURL); } function
I have JavaScript of ajax uploader as below; $(document).ready(function(){ var qwerty = $('#qwerty').val(); $('#demo1').ajaxupload({
I have a JavaScript file which has a function that I reference. When I
What does the below JavaScript mean? Why is the function embedded inside ()? (function()
I have an issue in my JavaScript function. Below is my js code: function
I am using the below function of javascript to enable and disable the radio
Below is the extend function in core javascript. It is same as $.extend() in
In the function below chld is null only in IE, in firefox the javascript

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.