jqueryForm and empty uploads

Posted by Aiden Bell on Stack Overflow See other posts from Stack Overflow or by Aiden Bell
Published on 2010-05-18T09:45:39Z Indexed on 2010/05/18 9:51 UTC
Read the original article Hit count: 314

Filed under:
|
|
|

Hi All,

Been scratching my head for too long on this: Using jquery.form, (http://malsup.com/jquery/form) with PHP ... my $_FILES['someimage'] gets set but the error number is always UPLOAD_ERR_NO_FILE, size is also 0.

The JavaScript:

$('form input[type=file]').change(function(){
        $(this).clone().appendTo('#imgform');
        $('#imgform').ajaxForm();
        $('#imgform').ajaxSubmit(
            {
                type:'POST'
            }
        );
});

Which appends to:

<form id="imgform" method="POST" action="/api/images.php" enctype="multipart/form-data"></form>

From another form which has bog-standard file inputs.

PHP logs are clean, but var_dumping $_FILES always shows that the index is set to the name of the form element ... but no data.

Thanks guys! (Sorry, I know jQuery-like questions are too frequent round these parts).

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jqueryform