I scratched my head too long: using jquery.form, ( http://malsup.com/jquery/form ) with PHP ... my $_FILES['someimage'] set, but the error number is always UPLOAD_ERR_NO_FILE , the size is also 0 .
JavaScript:
$('form input[type=file]').change(function () { $(this).clone().appendTo('#imgform'); $('#imgform').ajaxForm(); $('#imgform').ajaxSubmit({ type: 'POST' }); });
What is added to:
<form id="imgform" method="POST" action="/api/images.php" enctype="multipart/form-data"></form>
From another form that has input files with files in the swamp.
PHP logs are clean, but var_dump ing $ _FILES always shows that the index is set to the name of the form element ... but there is no data.
Thanks guys! (Sorry, I know jQuery-like questions are too frequent around these parts).
EDIT I found the Clone file entry element in Javascript , which contains additional information and suggested alternatives.
What I decided to do was to have one form for browsers without JavaScript, and JavaScript / jQuery splits one form into three forms:
Head form -> File upload form -> tail form
Then I can post the file asynchronously, and when I click the submit tail, paste the form together in POST, as these are just text fields.
source share