Massimiliano,

That code wasn't meant to serve as an example.  It had a bunch of
extra stuff in there so that I could display the responses, etc.

You neglected to indicate what it not working for you.  Are you
getting an error?   There is nothing special that you need to do to
take advantage of the file upload capabilities.

Just start with something simple, like this:

<html><head>
<script type="text/javascript" src="js/jquery-latest.pack.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript">
$(document).ready(function(){
   $('#uploadForm').ajaxForm({
       target: '#uploadOutput',
       success: function(data) {
           alert('success!');
       }
   });
});
</script>
</head>
<body>
<form id="uploadForm" action="upload.php" method="POST"
enctype="multipart/form-data">
File: <input name="file" type="file">
<input type="submit" value="Invia">
</form>
<div id="uploadOutput"></div>
</body>
</html>


On 4/27/07, Massimiliano Marini <[EMAIL PROTECTED]> wrote:

Hi all,

I'm having problem with the upload form and I don't understan where
I'm in error, I'm trying to reproduce the example of Mike Alsup.

I explain what I've done

file index.html
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="js/jquery-latest.pack.js"></script>
     <script type="text/javascript" src="js/jquery.form.js"></script>

    <script type="text/javascript">
    $(document).ready(function(){
        // I don't undestand what exactly I must put here
        $('#uploadForm').ajaxForm({
        beforeSubmit: function(a,f,o) { // "o" is not necessary for me right?
                                        // "a" and "f" ?
            o.dataType = $('#uploadResponseType')[0].value; // I've removed 
tihs div is here the error? I don't need this
            $('#uploadOutput').html('Submitting...');
        },
        success: function(data) {
            var $out = $('#uploadOutput');
            $out.html('Form success handler received: <strong>' + typeof data + 
'</strong>');
            if (typeof data == 'object' && data.nodeType)
                data = elementToString(data.documentElement, true);
            else if (typeof data == 'object')
                data = objToString(data);
            $out.append('<div><pre>'+ data +'</pre></div>');
        }
    });

    });

    // I think this is necessary
    function objToString(o) {
    }
    // Also this
    function elementToString(n, useRefs) {
    }
    // I'm missing something else?
    </script>
</head>
    <body>
    <form id="uploadForm" action="upload.php" method="POST" 
enctype="multipart/form-data">
        File: <input name="file" type="file">
        <input type="submit" value="Invia">
    </form>
    <div id="uploadOutput"></div>
    </body>
</html>

--
Massimiliano Marini - http://www.linuxtime.it/massimilianomarini/
"It's easier to invent the future than to predict it."  -- Alan Kay

Reply via email to