Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php jqueryajax表单上传_Php_Jquery_Forms_Upload - Fatal编程技术网

Php jqueryajax表单上传

Php jqueryajax表单上传,php,jquery,forms,upload,Php,Jquery,Forms,Upload,下面是一个简单的ajax提交表单示例: $('#submit').click(function () { var myName = $('#name').val(); var myContent = $('#content').val(); // ajax $.ajax({ type: 'post', url: '/ajax.process.php', data: { post_name:

下面是一个简单的ajax提交表单示例:

$('#submit').click(function () {
    var myName = $('#name').val();
    var myContent = $('#content').val();

    // ajax
    $.ajax({
        type: 'post',
        url: '/ajax.process.php',
        data: {
            post_name: myName,
            post_content: myContent
        },
        dataType: 'json',
        success: function (data) {
            if (data.status.OK == 'OK') {
                console.log('OK');
                return false;
            } else {
                console.log('ERROR');
                return false;
            }
        }
    }); // end ajax
});
这是我的html:

   <form method='post' enctype='multipart/form-data' action='ajax.process.php' id='form-main'>
     <textarea cols='50' rows='5' id='content' name='post_content'></textarea>
         <input type='text' id='name' class=' name='post_name'>
         <input type='file' id='attach' name='attach'/>
          <input type='button' value='Submit' id='express-form-submit'>
   </form>


jquery无法发布这些文件,因为您无法访问它们的内容。另外,您不发布表单,而是使用jquery执行单独的ajax请求。

是否可能重复?你能再具体一点吗D