0

so i have this code

 $('#sepia').click(function () {
    var filePathName = tempFilePath;
    alert(filePathName);
    $.ajax({
        type: 'POST',
        url: 'php/sepia.php',
        data: {
            FilePath: filePathName
        },
        success: function (data) {
            pictureReset();
        }
    });
});

alert(filePathName) has the correct value test.jpg but as soon as its passed with

            data: {
                FilePath: filePathName
            }

the value is changes to incomprehensible text like this jhSerZR6i1T952C3bk7vEOGCj8Pz_tBYtuHcgrgj81A.

even if i replace filePathName with 'hp_2.jpg` i still get the same random letter message

never mind found the error. wasn't anywhere near that bit of code but when i came back to the script to use the file path name. added +"" at the end and fixed it :)

18
  • First guess? You have a reference to an /image/. Your alert statement is stringifying it, turning it into just a file name, but the POST is actually upload the image iself. Commented May 6, 2014 at 11:48
  • so if i passed FilePath: filePathName+'' would it fix it? Commented May 6, 2014 at 11:50
  • If my guess is right, it should. You could add a console.log(filePathName) right before your alert and see what it gives you. Commented May 6, 2014 at 11:51
  • it returns the correct filepath name as well, i added the '' and i still get that long string :( Commented May 6, 2014 at 11:55
  • OK.. second try: Look at your debugging tools Network tab and see what is actually being sent. If the string test.jpg is being sent, then the problem has to be on the server-side PHP code. Commented May 6, 2014 at 11:57

1 Answer 1

1

ok, lets try some else....

usual it's the same but it may gives a other result...

var tempFilePath = 'test.jpg';
$('#sepia').click(function () {
    var filePathName = tempFilePath;
    $.post('php/sepia.php', 
    {
        data:   {
                    //FilePath: filePathName changed to
                    fpath: filePathName
                }
    }).done(function(response){
        console.log(response);
    });
});

and add this to sepia.php:

<?php
    echo "<pre>";
    print_r($_POST);
    echo "</pre>";
    die();

    // rest of your code
?>

this should return

array( 
       "FilePath" => "test.jpg" 
);

in the console

Sign up to request clarification or add additional context in comments.

2 Comments

returns the incomprehensible string as well
just for try and error... change FilePath to fpath

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.