jquery passes data while uploading files to PHP backend issues

Source: Internet
Author: User
Keywords PHP Data jquery
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;}
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.