Javascript file submission causing server error in php script -
i've been going mad past month trying build page submit pdf asynchronously our server. i'm experienced programmer, never worked in web-dev or in php or javascript.
the javascript submission function follows:
function sendfile(event) { $("#submitform").hide(); var formdata = new formdata(); var file=$("#journal")[0].files[0]; formdata.append("document", file); $.ajax("converter.php", { data:formdata, processdata:false, datatype:"text", method:"post", success:function(data, textstatus, jqxhr){ if(data.length == 8) { $("#key_input").val(data); $("#key_submission").submit(); } else { $("#response").html(data); } } });
it submits server php script reaches line
if(isset($_post['document']))
the program crashes , internal server error. causing crash?
this should done $.ajax()
way:
$.ajax({ //<------"{" object should passed here missing "{" url:"converter.php", //<-----"url:" missing. data:formdata, contenttype:false, //<-----this needed file upload processdata:false, datatype:"text", type:"post", //<------should type not method success:function(data, textstatus, jqxhr){ if(data.length == 8){ $("#key_input").val(data); $("#key_submission").submit(); }else{ $("#response").html(data); } } });
if trying upload file contenttype:false
needed processdata:false
.
Comments
Post a Comment