No announcement yet.

Trying a manual file upload in SC

  • Filter
  • Time
  • Show
Clear All
new posts

  • Trying a manual file upload in SC

    Ok - just for kicks, I am trying to implement my own file uploader (because the SC version is sooooo cumbersome and inconsistent).

    I have tried, so far, on a control app - to add the following in the onLoad event:

    {Filename} = '<input name="fileuload" type="file">';
    Plus I added a label text field to the app called "Filename".

    This provides:


    So I get the upload button, which opens the file browser and gets the filename. And sure enough the variable [fileuload] contains the filename.


    However, that's all I get. I would have expected to get access to other info from that input element, like the path, file size etc - however looking at the $_POST array, only the filename is given as a global variable [fileuload]. I would have also perhaps expected the $_FILES array too, but this is empty. And before I actually upload the file, I would like to validate things about it first.

    So - any thoughts people how I get that info please?



  • #2
    Your file never get the server, you are not POSTing to it.

    Professional Scriptcase Services
    Some Customers opinions


    • #3

      lol good point. Looked at the links (first one describes what I have already done - which as you pointed out - doesn't work as I'm not POSTing!) - have you tried any from the second link?


      • #4
        Sorry, i didnt tried any of the options

        Professional Scriptcase Services
        Some Customers opinions


        • #5
          getting an uploader done is easy enough, thanks for the links page. There are a few I had not seen yet (fine uploader mainly).
          After the upload you still want to have your files in some database for the download link or you have to make your own with the whole security thing with it.
          That takes its time making as well, which is why I finally preferred to fix some bugs in the uploader from scriptcase.
          Let it be known that this was for SC7 and 7.1 I havent tried 8 yet in detail.


          • #6
            Thanks rr

            I would have a go at just fixing the SC uploader to suit me, but I cannot see where to start doing that :-(

            Also - having tried a few of the links Giu sent - implementing them to work in SC also seems a minefield (I'm fine with PHP, but JS I'm less familiar with). It seems reasonable, but I'm unsure where the JS calls go - is it in the onLoad (outside PHP tags)? Or in a JS Method under Programming? Or a mix?

            Likewise where to put the JS library these uploaders come with (so that the JS calls are resolved)....

            Sooooo many questions. I'm experimenting, but it's very time consuming.


            • #7
              Ok this is where I'm at.....

              I'm playing with a 3rd party JS file uploader - plupload (from 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>
              <script type="text/javascript">
              // Initialize the widget when the DOM is ready
              $(function() {
                  // Setup html5 version
                      // 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'
              // "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:

              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?
              2. 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?



              • #8
                Changing the url : '...', to "../" or "/" makes it work but I cannot find the file so it may not work after all...
                Last edited by HakLin0816; 10-17-2014, 10:04 AM.


                • #9
                  Thanks HakLin

                  To be honest I tried that first: "../../../file/doc/timesheets" - and varied the number of "../"s - but made no difference - which is why I ended up, in the snippet, to use the full URL.

                  When I do it - it looks like it works but then a small yellow triangle appears on the right of each file listed (under the Status column) - hovering over it it pops up "HTTP Error".


                  • #10
                    Actually - having re-read the documentation (which isn't bad but not very intuitive) I think "url" is actually where to find a self written php upload handler, and not the location to put the uploaded files. This does make some sense - so will carry on and experiment over next few days and report back.



                    • #11
                      Did you get anywhere with this?


                      • #12

                        Yes - making good progress - finally got it working last week! A tad convoluted but not tooooo complicated. I will post here (in next few days) what I did so others can try and see for themselves.


                        • #13
                          Originally posted by adz1111 View Post

                          Yes - making good progress - finally got it working last week! A tad convoluted but not tooooo complicated. I will post here (in next few days) what I did so others can try and see for themselves.
                          Good news adz1111,
                          Looking forward to your post then..


                          • #14
                            Took a while - but finally did it. Hit a few snags, and then work overtook everything... but finally got round to it (for what it's worth).