Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.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
jquery表单插件重新提交赢得';在使用上传时不要触发_Jquery_Forms - Fatal编程技术网

jquery表单插件重新提交赢得';在使用上传时不要触发

jquery表单插件重新提交赢得';在使用上传时不要触发,jquery,forms,Jquery,Forms,我怎样才能“活”我的jquery(表单插件)上传例程,如下所述 第一次单击按预期上载并刷新列表,但用户无法上载第二个文件,因为它似乎没有启动javascript,我尝试了几个与此插件的“.live('submit')”组合,但尚未解决: JQuery使用表单插件: $(document).ready(function() { var options = {target: '#uploads_panel', data:

我怎样才能“活”我的jquery(表单插件)上传例程,如下所述

第一次单击按预期上载并刷新列表,但用户无法上载第二个文件,因为它似乎没有启动javascript,我尝试了几个与此插件的“.live('submit')”组合,但尚未解决:

JQuery使用表单插件:

$(document).ready(function() {   
var options = {target: '#uploads_panel', 

                 data:
                     { upload_ajax_on:'1',
                               upload:'1'
                     }
              };

$('#upload-form').submit(function() {
    $(this).ajaxSubmit(options);
     return false;
});
});
表单如下所示:

 <div id='uploads_panel'> <!-- for ajax refresh -->
    //table containing existing file list
<form action="/file/upload" method="post" id="upload-form" enctype="multipart/form-data">
    <p>File<br />
    <input type="file" name="userfile" id="userfile" /></p>
    <p><input type="submit" value="Submit" /></p>
</form>
</div>
public function uploadAction()
{

//fetch variables etc

if(isset($_POST['upload']))
{
$data=array();
$data[name] = $_FILES['userfile']['name'];
$data[internal_name] = date("Y-m-d-h-m-s",time()).$data[name];
$data[type] = $_FILES['userfile']['type'];
$data[size] = $_FILES['userfile']['size'];
$data[path] = 'uploads/'. $_SESSION['customer_id'] . "/".$data[internal_name];
$data[upload_time] = time();
$data[user_id] = $_SESSION['user_id'];
$data[customer_id] = $_SESSION['customer_id'];

$tmpName = $_FILES['userfile']['tmp_name'];

$testervar=$uploadDir.$data[internal_name];
$result = move_uploaded_file($tmpName, $uploadDir.$data[internal_name]);

if (!$result)
{
    echo "Error uploading file";
    die;
}

$db = new DBitems();
 //   $last_id=$db->uploadFile($data);


}

$upload_ajax_on=$_POST['upload_ajax_on'];

$dbitems = new DBitems();
$filelist=$dbitems->selectFilesByCustomerId($_SESSION['customer_id']);
$this->registry->template->filelist =$filelist;


if(isset($upload_ajax_on))
{
$this->registry->template->setView('masterpage','layouts:ajax');
$this->registry->template->setView('contents','customers:table_upload');
}
else
{
$returnurl=$_POST['returnurl'];
$this->registry->router->redirect($returnurl);
}


}

您是否尝试过将表单移动到上载面板div之外?不确定是否受更新影响?希望有帮助?

您是否尝试过将表单移动到上载面板div之外?不确定是否受更新影响?希望有帮助?

没有问题,很高兴它排序了。没有问题,很高兴它排序了。