javascript - FormData is empty (in PHP) -
i have been using process form via ajax , jquery
$("#uploadbtn").click(function() { var formdata = new formdata($('form')[0]); //--formdata here, problem line $.ajax({ url: 'resources/ajax/ajax_upload_video.php', type: 'post', xhr: function() { xhr = $.ajaxsettings.xhr(); if (xhr.upload) { xhr.upload.addeventlistener('progress', progresshandlingfunction, false); } return xhr; }, success: function(msg) { log(msg); }, data: formdata, cache: false, contenttype: false, processdata: false }); });
it has been working fine. added second form on page (search on top, uploader on bottom)
i understand $('form')[0]
grab first form on page, naturally changed javascript $('form')[1]
. when console.log on it, correct form.
when hit upload button, php file says nothing posted. simplicity sake, php file this:
<?php var_dump($_post); ?>
i empty array. gave form want id , called way $('#uploadform')
.
i have 1 multi-select file input, hidden field , text input field.
what doing wrong formdata
object?
one side not, i've been developing page locally using wamp , moved our centos server online. php setting isn't same local environment? can't think of php setting have post
upload form
<form id="videouploadform" method="post" enctype="multipart/form-data" class="upload-form modal-edit-form"> <div class="modal-body"> <p> <div align="center" id="fileselect"> <input type="hidden" value="video" name="mediatype" id="mediatype" /> <input type="hidden" value="<?php echo $_get['reelid']; ?>" name="reelid" id="reelid" /> <input type="file" name="videos[]" id="videos" accept="video/mp4" multiple /> </div> <br> </p> <p> <div id="dropbox"> <ul class="hide" id="filelist"> </ul> <div align="center" id="nofiles">select file begin</div> </div><br> </p> <p> <hr> <label>search tags <small>[at least 2 tags separate comma]</small></label> <input type="text" class="span5" name="searchtags" id="searchtags" disabled /> </p> <hr> <p align="center"> <img src="resources/img/loader.gif" class="hide" id="loader" /> <button type="button" class="btn btn-info" name="uploadbtn" id="uploadbtn" disabled><i class="icon-circle-arrow-up icon-white"></i> begin upload</button> <div id="successfulupload" class="alert alert-success hide"> <b>the videos have been uploaded.</b><br/> </div> </p> </div> </form>
try accessing way:
var form = document.getelementbyid('form-id'); var formdata = new formdata(form);
from this page on formdata.
Comments
Post a Comment