-1

I have a php file in which a GET a variable from another PHP file.Now I want to pass this variable to another PHP file which is given inside Javascript. How can I do that? Here is the code from Uploadify

<head>


<script type="text/javascript" src="uploadifyit/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="uploadifyit/swfobject.js"></script>
<script type="text/javascript" src="uploadifyit/jquery.uploadify.v2.1.4.min.js">     
<script type="text/javascript">

$(document).ready(function() {

//alert('I am ready to use uploadify!');
$("#file_upload").uploadify({
    'uploader': 'uploadifyit/uploadify.swf',
    'script': 'uploadifyit/uploadify.php',
    'cancelImg': 'uploadifyit/cancel.png',
    'folder': 'uploads',
    'auto': false, // use for auto upload
    'multi': true,
    'queueSizeLimit': 200,
    'onQueueFull': function(event, queueSizeLimit) {
        alert(" You can upload " +    queueSizeLimit + " files at once");
        return false;
    },
    'onComplete': function(event, ID, fileObj, response, data) {
        // you can use here jQuery AJAX method to send info at server-side.
        $.post("insert.php", { name: fileObj.name},   function(info) {
            alert(info); // alert UPLOADED FILE NAME
        });
    }
     });

        });

       </script>

      </head>

      <body>
      <?php
      $tabname=$_GET['tabname'];
      ?>

      <form id="form1" name="form1" action="">
      <input type="file" id="file_upload" name="file_upload" /><br />
       <a href="javascript:$('#file_upload').uploadifyUpload();">Upload File</a>
      </form>
      </body>
      </html>

See the section, $tabname is the variable I want to use in insert.php. I need to pass this $tabname to insert.php and use it within that..Thanks in advance

1
  • 2
    Use SESSIONS, global, cookies. These can be accessed from any PHP file. No need to pass them. Commented Dec 10, 2012 at 8:59

2 Answers 2

1

You can use the script data tag:

'scriptData'     :{
    'variable1': '<?php echo $_GET["variable1"]; ?>',
    'variable2': '<?php echo $_GET["variable2"]; ?>'
},

Or, why don't you store the variables in a $_COOKIE or $_SESSION variable? You can access these variables in the other script without needing to pass anything.

1
  • Thank you..I used SESSION and it is working superb.. Commented Dec 10, 2012 at 14:58
0

Change your post line to this:

$.post("insert.php?tabname="<?=$_GET['tabname'];?>, { name: fileObj.name},   function(info)
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.