-1

i am using this plugin but all works well less one thing. In the example of developper in the final of upload is showed 3 info about the file I want do something like that.

 <script type="text/javascript">
        $(function() {
            $('#userfile').change(function() {
                $(this).upload('thumb.php', function(res) {
                    $(res).insertAfter(this);
                }, 'html');
            });
        });

      </script>
    </head>
    <body>

        <input type="file" name="userfile" id="userfile">
        <br />

At the moment only the image is uploaded and none message is showed.

The question is, in my php file i test a simple echo that is not showed in .html().

this is the example of the dev

if (move_uploaded_file($_FILES['yourkey']['tmp_name'], '/path/to/save/' . $filename)) {
    $data = array('filename' => $filename);
} else {
    $data = array('error' => 'Failed to save');
}

header('Content-type: text/html');
echo json_encode($data);

in my case i just test with a echo "success";

what i am doing wrong?

PS: awesome plugin

3
  • Try to alert(res) in upload event - what is the output ? Commented Apr 15, 2011 at 16:00
  • i already tested an alert() but nothing happens. simple upload the photo and stops the load of the page Commented Apr 15, 2011 at 16:04
  • no, the firebug console is clean Commented Apr 15, 2011 at 16:13

1 Answer 1

1

Here is few reasons why your application does not work:

 $(this).upload('thumb.php', function(res) {$(res).insertAfter(this);}, 'html');

in this case upload sends to function a string element which you are trying to convert to DOMnode, so result of res suppose to be some html structure like

<li>some text</li>

your php code return JSON string which is treated as simple string by uploader if you are planning to use JSON formatted response change lasta parameter of $(this).upload(); from 'html' to 'json'

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

Comments

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.