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 ;}