"Mobile uploads" jquery to pass data while uploading files to the PHP background is not acceptable issues
Source: Internet
Author: User
KeywordsPHP Mobile jquery
PHP Mobile jquery
Dear predecessors, This problem has plagued me for a long time, this is my previous question, I downloaded an incomplete source on the Internet: The front end has an upload box, upload the image will automatically generate a preview, but the background php page with post method or file method can not receive the uploaded files, Text data can be received. The great God told me to say with form.js plug-in, the younger brother is not how to do not, so ask the big God to tell the details of the operation, where to add what is good? The code is as follows:
HTML code
JS Code
function Uploadpreview (files) {if (!window. FileReader) {}//Here are some conditions $ (". File-show"). HTML ("Preview loading ..."); 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) {}// The addtopic.php page does not receive anything {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;}
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.