Question about uploading files to the php background simultaneously using jQuery

Source: Internet
Author: User
Hello, everyone, I am a student who is learning programming by myself. The following figure shows a mobile app for uploading pictures: 1. there is an upload box at the front end. after an image is uploaded, a preview is automatically generated. the following program is part of the js file, some irrelevant code has been deleted, 3. background post. the post or file methods on the php page do not receive the uploaded files. text data can be received. get $ (& quot; # picture & quot;) from the front end ;). val () code. didn't my js pass the file successfully? What is missing? The preview chart can be generated normally! Thank you! & Quot; functionpo php Data jquery

Hello, everyone. I am a student and I am studying programming by myself. The following figure shows a mobile app for uploading images:
1. there is an upload box at the front end. a preview image is automatically generated after the image is uploaded.
2. the following programs are part of js files and some irrelevant code has been deleted,
3. The post. php page in the background cannot receive the uploaded file by using the post or file method, and text data can be received.
4. the front-end has the code $ ("# picture"). val (). didn't I upload the file successfully in this js? What is missing? The preview chart can be generated normally! Thank you!

Function postTopic () {var cid = $ ('# Cid '). val (); if (parseInt (cid) <1) {alert ("select a category"); $ ('# 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") {// unrelated code}, "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.