php手机jquery
各位前辈们好,这个问题困扰我挺长时间了,这是我之前的提问,我在网上下载的一份不完整源码:前端有一个上传框,上传图片后会自动生成预览图,可是后台php页面用post方法或者file方法都收不到上传的文件,text文本数据可以收到。有大神告诉我说用form.js插件,小弟不才怎么弄也不会,所以求大神告知详细一点的操作,在哪里添加什么才好?代码如下:
html代码
js代码
function uploadpreview(files){ if( !window.filereader ){} //此处为一些条件 $(.file-show).html(预览加载中...); var reader = new filereader(); reader.onload = function(e) { $(.file-show).html(); $().appendto($(.file-show)).click(function() { $(this).remove(); $(#picture).val(); }); } reader.readasdataurl(files[0]);}function posttopic() { var msg = $.trim($('textarea[name=message]').val()); var picture = ; picture = $(#previewimg).attr(src); $(.loading).show(); $(#add-topic-form).hide(); $.post(addtopic.php,{do:addtopic,msg:msg,picture:$(#picture).val()},function(data){} //在addtopic.php页面接收不到东西 { if (data.result == login) { location.href = ./passport.php; } else if (data.result == success) { location.href = ./?cid= + $('input[name=cid]').val(); } else if (data.result == error) { alert(data.message); $(.loading).hide(); $(#add-topic-form).show(); $('html, body').animate({scrolltop: $(document).height()}, 300); } },json); return false;}