PHP Data jquery
Good god, I am a student is self-learning programming, a mobile phone upload picture program as follows:
1. The front-end has an upload box, upload the image will automatically generate a preview map
2. The following program is part of the JS file, some irrelevant code has been deleted,
3. Background post.php Page The Post method or file method can not receive the uploaded files, text text data will be received
4. The front end has received $ ("#picture"). Val () of the code, I this JS is not a successful file transfer ah? What's missing? The preview map can be generated normally! Ask the Great God to guide twos, younger brother grateful!
function postTopic(){ var cid = $('#cid').val(); if( parseInt(cid) < 1 ) { alert("请选择分类"); $('#cid').focus(); return false; } var msg = $.trim($('textarea[name=message]').val()); if( msg.length > 500 ) { $('textarea[name=message]').focus(); return false; } var picture = ""; if( $("#picture").val() == "" ) { if( msg.length < 1 ) { $('textarea[name=message]').focus(); return false; } } else { picture = $("#previewImg").attr("src"); } $(".loading").show(); $("#add-topic-form").hide(); $.post("post.php",{"do":"addTopic","cid":cid,"msg":msg,"picture":$("#picture").val()},function(data) { if (data.result == "success") { //无关代码 },"json"); return false;}