Jump to content

Javascript to PHP variable


phpboy06

Recommended Posts

i downloaded a Multi File upload from http://www.plupload.com/.. i want to know how to pass the variable from my php to javascript..

 

main.php

switch($action)

{

case 'viewcontentwithin':

{

$path = $_GET['path'];// the directory where i would like to save the file dir=uploaded/capacitymanagement/EMVI

echo "<b>".$path."</b><br>";?>

<a href="?ref=newfolderwithin&dir=<? echo $path; ?>"><b>Create New Folder Here</a> |

<a href="upload/examples/jquery/jquery_ui_widget.php?ref=uploadfiles&dir=<? echo $path; ?>">Upload Files Here</a></b><br><br>

<?

$dir = opendir($path);

readdir($dir);

readdir($dir);

 

?><table border="0" class="main">

<tr><th><h3>Action</h3></th></td>

<th><h3>DIR/FILES</h3></th></td>

</tr>

 

<?

do

{

$file=readdir($dir);

$fullpath = $path."/".$file;

$link = "?actionfolder=viewcontentwithin&path=$fullpath";

if(is_dir($fullpath)) {

?>

<tr>

-----------------------------------------------------------------------------------------------------------------------

jquery_ui_widget.php

 

<?

$dir = $_GET['dir'];

echo $dir; i pass the variable $dir here from my main.php .. and i think that the back end of this .php file is the upload.php. i would like to save the file that depends on what folder locations i want...

example path.. (upload/sample1), (upload/sample2), (upload/sample3).

pls help me.. i am new in javascript to php.. tnx..

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">

<head>

<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>

 

<style type="text/css">

body {

font-family:Verdana, Geneva, sans-serif;

font-size:13px;

color:#333;

background:url(../bg.jpg);

}

</style>

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" />

<link rel="stylesheet" href="../../js/jquery.ui.plupload/css/jquery.ui.plupload.css" type="text/css" />

 

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>

<script type="text/javascript" src="http://bp.yahooapis.com/2.4.21/browserplus-min.js"></script>

 

<script type="text/javascript" src="../../js/plupload.js"></script>

<script type="text/javascript" src="../../js/plupload.gears.js"></script>

<script type="text/javascript" src="../../js/plupload.silverlight.js"></script>

<script type="text/javascript" src="../../js/plupload.flash.js"></script>

<script type="text/javascript" src="../../js/plupload.browserplus.js"></script>

<script type="text/javascript" src="../../js/plupload.html4.js"></script>

<script type="text/javascript" src="../../js/plupload.html5.js"></script>

<script type="text/javascript" src="../../js/jquery.ui.plupload/jquery.ui.plupload.js"></script>

 

<!--<script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script>-->

</head>

<body>

 

 

 

 

<form  method="post" action="dump.php">

<div id="uploader">

<p>You browser doesn't have Flash, Sirelverlight, Gears, BrowserPlus or HTML5 support.</p>

</div>

</form>

<script type="text/javascript">

// Convert divs to queue widgets when the DOM is ready

$(function() {

$("#uploader").plupload({

// General settings

 

runtimes : 'flash,html5,browserplus,silverlight,gears,html4',

url : '../upload.php',

max_file_size : '1000mb',

max_file_count: 100, // user can add no more then 20 files at a time

chunk_size : '1mb',

unique_names : true,

multiple_queues : true,

 

// Resize images on clientside if we can

resize : {width : 320, height : 240, quality : 90},

 

// Rename files by clicking on their titles

rename: true,

 

// Sort files

sortable: true,

 

// Specify what files to browse for

filters : [

{title : "Image files", extensions : "jpg,gif,png,bmp"},

{title : "Zip files", extensions : "zip,avi"}

],

 

// Flash settings

flash_swf_url : '../../js/plupload.flash.swf',

 

// Silverlight settings

silverlight_xap_url : '../../js/plupload.silverlight.xap'

});

 

// Client side form validation

$('form').submit(function(e) {

var uploader = $('#uploader').plupload('getUploader');

 

// Validate number of uploaded files

if (uploader.total.uploaded == 0) {

// Files in queue upload them first

if (uploader.files.length > 0) {

// When all files are uploaded submit form

uploader.bind('UploadProgress', function() {

if (uploader.total.uploaded == uploader.files.length)

{

$('form').submit();

 

}

});

 

uploader.start();

} else

alert('You must at least upload one file.');

 

e.preventDefault();

}

});

 

});

</script>

</body>

</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.