如何在ajax图像上传中将变量从index.php发送到ajaximage.php?(How to send variables from index.php to ajaximage.php in

编程入门 行业动态 更新时间:2024-10-23 17:36:36
如何在ajax图像上传中将变量从index.php发送到ajaximage.php?(How to send variables from index.php to ajaximage.php in ajax image uploading?)

我需要将用户logid和输入ID发送到服务器以及使用jquery上传的图像。 我发送的只是图像。 这是我目前的代码:index.php

<?php include('db.php'); session_start(); $session_id='1'; //$session id ?> <script type="text/javascript" src="scripts/jquery.min.js"></script> <script type="text/javascript" src="scripts/jquery.form.js"></script> <script type="text/javascript" > $(document).ready(function() { $('.photoimg').live('change', function() { var id=$(this).attr("id"); var split=id.split("photoimg"); var splited=split[1]; alert(splited); $("#preview").html(''); $("#preview").html('<img src="loader.gif" alt="Uploading...."/>'); $("#imageform").ajaxForm({ target: '#preview' }).submit(); }); }); </script> <form id="imageform" method="post" enctype="multipart/form-data" action='ajaximage.php'><br> Upload your image1 <input type="file" name="photoimg" id="photoimg1" class="photoimg"/><br> Upload your image2 <input type="file" name="photoimg" id="photoimg2" class="photoimg"/><br> Upload your image3 <input type="file" name="photoimg" id="photoimg3" class="photoimg"/><br> </form> <div id='preview'> </div>

请帮忙

I need to send users logid and input id to server along with image uploaded with jquery. Only thing i get to send is image. Here is my current code: index.php

<?php include('db.php'); session_start(); $session_id='1'; //$session id ?> <script type="text/javascript" src="scripts/jquery.min.js"></script> <script type="text/javascript" src="scripts/jquery.form.js"></script> <script type="text/javascript" > $(document).ready(function() { $('.photoimg').live('change', function() { var id=$(this).attr("id"); var split=id.split("photoimg"); var splited=split[1]; alert(splited); $("#preview").html(''); $("#preview").html('<img src="loader.gif" alt="Uploading...."/>'); $("#imageform").ajaxForm({ target: '#preview' }).submit(); }); }); </script> <form id="imageform" method="post" enctype="multipart/form-data" action='ajaximage.php'><br> Upload your image1 <input type="file" name="photoimg" id="photoimg1" class="photoimg"/><br> Upload your image2 <input type="file" name="photoimg" id="photoimg2" class="photoimg"/><br> Upload your image3 <input type="file" name="photoimg" id="photoimg3" class="photoimg"/><br> </form> <div id='preview'> </div>

Please help

最满意答案

您可以将参数添加到表单的操作,如下所示:

<form id="imageform" method="post" enctype="multipart/form-data" action='ajaximage.php?logid=XXX'>

或者如果var是PHP可能:

<form id="imageform" method="post" enctype="multipart/form-data" action='ajaximage.php?logid=<?php echo $logId;?>'>

然后在ajaximage.php中处理它:

$_GET['logid']

Can you add the parameters to the action of the form as follows:

<form id="imageform" method="post" enctype="multipart/form-data" action='ajaximage.php?logid=XXX'>

or if the var is PHP which is likely:

<form id="imageform" method="post" enctype="multipart/form-data" action='ajaximage.php?logid=<?php echo $logId;?>'>

and then process it in ajaximage.php with:

$_GET['logid']

更多推荐

本文发布于:2023-08-05 00:16:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1423315.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发送到   中将   变量   图像   上传

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!