Ok this is where I’m at…
I’m playing with a 3rd party JS file uploader - plupload (from http://www.plupload.com if anyone is interested). I’m having moderate success; I’m soooooo close but just can’t quite nail it.
I suspect it’s more the conceptual level I’m tripping up on. However, it’s definitely worth figuring out as it will be very helpful for ALL SC developers for all sorts of things - assuming it is possible.
I downloaded the JS uploader and created a “js” folder under the “scriptcase” folder. I then created a control app with one text label field which I assigned a message in the app’s OnLoad event: “Use this screen to upload a PDF or an image file of your timesheet (max. size 2MB) AFTER the upload has completed click ‘Exit’ below.<br/>”. I removed all toolbar buttons except one exit button (so the app itself just looks like a dialog box with some text and an “Exit” button).
Then in the app’s onApplicationInit event I have this code (as per plupload’s documentation):
// This lot uses the plupload plugin... start off "closing" PHP, i.e. straight HTML
?>
<link href="../../../js/jquery.plupload.queue/css/jquery.plupload.queue.css" type="text/css" rel="stylesheet" media="screen">
<script src="../../../js/plupload.full.min.js" type="text/javascript"></script>
<script src="../../../js/jquery.plupload.queue/jquery.plupload.queue.js" type="text/javascript"></script>
<div id="uploader">
<p>Your browser doesn't have Flash, Silverlight or HTML5 support.</p>
</div>
<br/>
<script type="text/javascript">
// Initialize the widget when the DOM is ready
$(function() {
// Setup html5 version
$("#uploader").pluploadQueue({
// General settings
runtimes : 'html5,flash,silverlight,html4',
url : '/opt/NetMake/v8/wwwroot/scriptcase/file/doc/timesheets',
chunk_size : '1mb',
rename : true,
dragdrop : true,
multi_selection : false,
filters : {
// Maximum file size
max_file_size : '2mb',
// Specify what files to browse for
mime_types: [
{title : "Image files", extensions : "jpg,gif,png"},
{title : "PDF files", extensions : "pdf"}
]
},
// Resize images on clientside if we can
resize: {
width : 200,
height : 200,
quality : 90,
crop: true // crop to exact dimensions
},
// Flash settings
flash_swf_url : '../../../js/Moxie.swf',
// Silverlight settings
silverlight_xap_url : '../../../js/Moxie.xap'
});
});
</script>
<?php
// "re-open" PHP
Running that app (which I open modally via an HTML Image “button” with a link to the control app) produces …
It works perfectly, in that “Add Files” opens an “open File” dialog. It also lets me drag files to the “drag” area. However when I click “start upload” I get “HTTP Error”. So 2 questions:
[B][LIST=1]
Does anyone know what SC does with the standard uploader to make it work? Is it a "wrapper" type issue I need to overcome?
If the JS has variable values like "url", is it possible to access those values in PHP? I appreciate one is client-side and one is server-side, so I suspect not - in which case any further file validation I may want will need to occur in the JS?
[/LIST][/B]
Thanks.
