colonymech / docs / www / colonyscout / internal / uploadify / uploadify-scriptData.php @ f59acf11
History | View | Annotate | Download (5.45 KB)
1 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
---|---|
2 |
<head>
|
3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
4 |
<title>Uploadify scriptData Sample</title> |
5 |
|
6 |
<link rel="stylesheet" href="uploadify/uploadify.css" type="text/css" /> |
7 |
|
8 |
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> |
9 |
<script type="text/javascript" src="js/jquery.uploadify.js"></script> |
10 |
|
11 |
<script type="text/javascript"> |
12 |
function startUpload(id, conditional)
|
13 |
{
|
14 |
if(conditional.value.length != 0) {
|
15 |
$('#'+id).fileUploadStart();
|
16 |
} else
|
17 |
alert("You must enter your name. Before uploading");
|
18 |
}
|
19 |
</script>
|
20 |
<script type="text/javascript"> |
21 |
|
22 |
|
23 |
$(document).ready(function() {
|
24 |
$("#fileUploadname").fileUpload({
|
25 |
'uploader': 'uploadify/uploader.swf',
|
26 |
'cancelImg': 'uploadify/cancel.png',
|
27 |
'script': 'uploadify/upload_name.php',
|
28 |
'folder': 'files',
|
29 |
'multi': false,
|
30 |
'displayData': 'percentage',
|
31 |
onComplete: function (evt, queueID, fileObj, response, data) {
|
32 |
alert("Successfully uploaded: "+response);
|
33 |
}
|
34 |
});
|
35 |
|
36 |
$("#fileUploadname2").fileUpload({
|
37 |
'uploader': 'uploadify/uploader.swf',
|
38 |
'cancelImg': 'uploadify/cancel.png',
|
39 |
'script': 'uploadify/upload_name.php',
|
40 |
'folder': 'files',
|
41 |
'multi': true,
|
42 |
'displayData': 'percentage',
|
43 |
'scriptData': {'name':'JohnDoe'}, // If the value is known to php you can also enter it here ie < ?= $value ?> or < ?= $_RESULT['value'] ?>
|
44 |
onComplete: function (evt, queueID, fileObj, response, data) {
|
45 |
alert("Successfully uploaded: "+response);
|
46 |
}
|
47 |
});
|
48 |
|
49 |
$("#fileUploadname3").fileUpload({
|
50 |
'uploader': 'uploadify/uploader.swf',
|
51 |
'cancelImg': 'uploadify/cancel.png',
|
52 |
'script': 'uploadify/upload_name.php',
|
53 |
'folder': 'files',
|
54 |
'multi': true,
|
55 |
'displayData': 'percentage',
|
56 |
'scriptData': {'name':'JohnDoe', 'location':'Australia'},
|
57 |
onComplete: function (evt, queueID, fileObj, response, data) {
|
58 |
alert("Successfully uploaded: "+response);
|
59 |
}
|
60 |
});
|
61 |
|
62 |
$('#name').bind('change', function(){
|
63 |
$('#fileUploadname').fileUploadSettings('scriptData','&name='+$(this).val());
|
64 |
});
|
65 |
$('#name2').bind('change', function(){
|
66 |
$('#fileUploadname2').fileUploadSettings('scriptData','&name='+$(this).val());
|
67 |
});
|
68 |
|
69 |
// When setting scriptData you must enter the full parameter string. More checks need to be done in this case
|
70 |
// because what you will experience is if you enter a name it will wipe location:Australia unless Australia is
|
71 |
// written in the location field. The same applies visa versa, the only difference is there is an "isEmpty" check
|
72 |
// on the name field.
|
73 |
$('#name3').bind('change', function(){
|
74 |
$('#fileUploadname3').fileUploadSettings('scriptData','&name='+$(this).val()+'&location='+$('#location').val());
|
75 |
});
|
76 |
$('#location').bind('change', function(){
|
77 |
$('#fileUploadname3').fileUploadSettings('scriptData','&name='+$('#name3').val()+'&location='+$(this).val());
|
78 |
});
|
79 |
|
80 |
});
|
81 |
|
82 |
</script>
|
83 |
</head>
|
84 |
|
85 |
<body>
|
86 |
<fieldset style="border: 1px solid #CDCDCD; padding: 8px; padding-bottom:0px; margin: 8px 0"> |
87 |
<legend><strong>Upload Files - scriptData Sample with Response</strong></legend> |
88 |
<p>Name is not known at execution of this file.</p> |
89 |
<strong>Name: </strong> |
90 |
<input name="name" id="name" type="text" maxlength="255" size="50" /> |
91 |
<br /><br /> |
92 |
<div id="fileUploadname">You have a problem with your javascript</div> |
93 |
<a href="javascript:startUpload('fileUploadname', document.getElementById('name'))">Start Upload</a> | <a href="javascript:$('#fileUploadname').fileUploadClearQueue()">Clear Queue</a> |
94 |
<p></p> |
95 |
<hr width=100% size="1" color="" align="center"> |
96 |
<p>Name is known at execution of this file, but can be overridden.</p> |
97 |
<strong>Name: </strong> |
98 |
<!-- Adding the value="John Doe" does not update the scriptData. It purley gives startUpload() something to pass in the conditional,
|
99 |
and if the user deletes the name it will still trigger the alert -->
|
100 |
<input name="name2" id="name2" type="text" maxlength="255" size="50" value="John Doe"/> |
101 |
<br /><br /> |
102 |
<div id="fileUploadname2">You have a problem with your javascript</div> |
103 |
<a href="javascript:startUpload('fileUploadname2', document.getElementById('name2'))">Start Upload</a> | <a href="javascript:$('#fileUploadname2').fileUploadClearQueue()">Clear Queue</a> |
104 |
<p></p> |
105 |
<hr width=100% size="1" color="" align="center"> |
106 |
<p>Multiple scriptData Inputs</p> |
107 |
<strong>Name: </strong> |
108 |
<!-- Adding the value="John Doe" does not update the scriptData. It purley gives startUpload() something to pass in the conditional,
|
109 |
and if the user deletes the name it will still trigger the alert -->
|
110 |
<input name="name3" id="name3" type="text" maxlength="255" size="50" value="John Doe"/> |
111 |
<br /><br/> |
112 |
<!-- You can see how not using value="Australia" here that scriptData with a predefined value still works. Enter something in the
|
113 |
field and it'll update the location -->
|
114 |
Try leaving this blank first. Then try just changing the name, Now enter a location. Read the comments on the file to find out what's happening<br>
|
115 |
<strong>Location: </strong> |
116 |
<input name="location" id="location" type="text" maxlength="255" size="50" /> |
117 |
<br /><br /> |
118 |
<div id="fileUploadname3">You have a problem with your javascript</div> |
119 |
<a href="javascript:startUpload('fileUploadname3', document.getElementById('name3'))">Start Upload</a> | <a href="javascript:$('#fileUploadname3').fileUploadClearQueue()">Clear Queue</a> |
120 |
<p></p> |
121 |
</fieldset>
|
122 |
</body>
|
123 |
</html>
|