Ajaxfileupload uploading files didn't respond.

Source: Internet
Author: User
function Ajaxfileupload () {$.ajaxfileupload ({url: ' upfile.php ', Secureuri:false, Fileelementid: ' pic ', DataType: ' JSON ',            success:function (data, status) {                if (typeof (Data.error)! = ' undefined ') {                    if (data.error! = ') {                        alert (data.error);                    } else{                        alert (data.msg);}}            ,            error:function (data, status, E) {                alert (e);}}            )  return false;}


+ Add a picture


upfile.php
$upFilePath = ". /useruploaddatas/". $_session ["UserId"]. "/"; $res ["error"] = ""; Error message $res ["msg"] = "exec"; Hint Information if (copy ($_files [' pic '] [' tmp_name '], $upFilePath. $_files [' pic '] [' name ']) {$res ["msg"] = "OK";} else {$re s ["error"] = "error";} echo Json_encode ($res);


Unable to upload the file, do not know where there is a problem ... I hope the warrior pointed


Reply to discussion (solution)

Who's the Boss?

Make sure your JS section doesn't have a big difference from the sample file.

Check to make sure the file is not uploaded.
Exit (Json_encode ($_files));

JS script is not error Ah, you are under the Firebug console to see there is no error.

I just tested it under FF.

Without any hint of error, it made me very embarrassed.

Get not to file, what's going on.

Full code:
Upload file Form upfileform.php

 
  
 
  Website Column Management
 
  



Upload file server side upfile.php
!--? phpheader ("content-type:text/html; Charset=utf-8 "); $upFilePath =". /useruploaddatas/". $_session ["UserId"]. " /"; $res [" error "] =" "; Error message $res ["msg"] = ""; Hint Information if (@move_uploaded_file (@$_files ["Filetoupload"] ["Tmp_name"], $upFilePath. @$_files ["Filetoupload"] ["name"] ) {$res ["msg"] = "OK";} else {$res ["error"] = "error";}  echo Json_encode ($res);  

can't live Ajax upload Ah, direct
 files can be uploaded, I am not clear, how I write the above code to AJAX upload files, depressed a few days,, do not know why. 

first remove

Look, there may be a conflict

boss, has removed the jrosion.js, the same effect. 。

you write only in upfile.php

!--? Phpecho ' {"msg": "Hello "}'; Try 
Note that there must be no BOM header

I can't stand, downloaded a wrong ajaxfileupload.js file, and finally downloaded one in csdn, no problem, I'm depressed not, as if in Download the website ....

  • 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.